ChartJs Format numbers

0
0

Hello, does someone know how to format numbers (thousand point,etc) in chartJS?

Or simply cant do that in wisej?

 

  • Jun
    • Jun
    • May 10, 2024 - 2:08 pm
    or sertting locale option?
  • You must to post comments
0
0

If you can do it in ChartJS via JavaScript, then you can do it in Wisej. So it should be possible.

As for what javascript to write, check out this StackOverflow post: https://stackoverflow.com/questions/25880767/chart-js-number-format

Note that some of the examples have you set the “options” of the ChartJS widget. You can read the Wisej documentation on widget options here: https://docs.wisej.com/api/wisej.web/content/widget#options

Other useful Wisej documentation:
https://docs.wisej.com/docs/concepts/javascript
https://docs.wisej.com/docs/controls/content/widget

 

 

You also mention setting the locale. You can try the ToLocaleString() method: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString

Here’s an example of using ToLocaleString with the Eval function. (Eval lets you call javascript code from C#. In this case, the javascript code is  var x= 123456.789; x.toLocaleString('en-US'); )

Application.Eval("var x= 123456.789; x.toLocaleString('en-US');", (r) => { AlertBox.Show(r.ToString()); });

And here’s an example with EvalAsync:
var result = await Application.EvalAsync("var x= 123456.789; x.toLocaleString('en-US');");
AlertBox.Show(result);

  • Jun
    • Jun
    • May 14, 2024 - 9:59 pm
    Thanks Julie I will try.!
  • Jun
    • Jun
    • May 15, 2024 - 9:12 pm
    i tried using widget, eval, etc but could not format the numbers. Can you make a sample? I believe the problem resides in the nuget package itselft. It should be simple and direct for such a basic configuration…
  • Luca (ITG)
    Send a test case with the code that is not working for you. There is nothing wrong in the nuget package itself.
  • Jun
    • Jun
    • May 16, 2024 - 7:24 pm
    Well it did work on serverside, Simnply create a list (of strings) to add the data objects in it using your desired format. (#,### etc) then add the list in yout dataset “formatted” property . And thats it. both datalabel and tooltip is formated. I could not figure it out using javascript. No idea how to callback with this object. Will figure it out later.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.