function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BroncoBoyBroncoBoy 

Visualforce Chart apex:barSeries, Currency

Anyone know how to re-format a number to currency (or at least have the commas) and display on a apex:barSeries chart?

Right now the left axis is displaying several #'s, for example: 10000.   I would prefer 10,000 or, even better, $10,000.

The source data is coming from a number type field from a custom object.  I'm also wondering if I convert the field to type: currency if that would help?

Thanks in advance!
Bronco
ManojSankaranManojSankaran

Hi BroncoBay,

Convert your deciaml value to string and send that to this method it will give you the formated string.

String i = '10000000.00';
String s = ( Decimal.valueOf(i==null||i.trim()==''?'0':i).setScale(2) + 0.001 ).format();
s.substring(0,s.length()-1);


Let me know if you face any issues formating the string.

Thanks

Manoj S

BroncoBoyBroncoBoy

Thank you Manoj, the code formats correctly.

But if I send these values to an apex:barSeries component, will this work now that it's a string?  Can it still be used as a number for the bar chart?

Thanks,

Bronco