Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Format currency in beforegeneration Chart Event
BirtRepUser
I am trying to format Number in beforegeneration Chart Event.I would like to format number based on locale.
var formatter = new Packages.org.eclipse.birt.core.format.NumberFormatter("###.00");
var value = formatter.format(icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("val"));
If the number is 24335.801234, after formatting it displays 24335.80 on chart. But I would like to display it as 24,335.80 on chart . How can I do that ?
Here is my code
function beforeGeneration( chart, icsc )
{
importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
importPackage(Packages.org.eclipse.birt.chart.model.attribute);
importPackage(Packages.org.eclipse.birt.chart.model.attribute.impl);
importPackage(Packages.org.eclipse.birt.chart.model.component.impl);
var formatter = new Packages.org.eclipse.birt.core.format.NumberFormatter("###.00");
var value = formatter.format(icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("val"));
var chart = icsc.getChartInstance();
var xAxis =chart.getAxes().get(0);
var yAxis = chart.getAxes().get(0).getAssociatedAxes().get(0);
var Units = icsc.externalContext.scriptable.getParameterValue("_Units");
if (Units != null)
{
Units = " (" +Units + ")";
}
else
{
Units = "";
}
Total_ml = MarkerLineImpl.create(xAxis,NumberDataElementImpl.create(value));
Total_ml.getLabel().getCaption().setValue("Total : "+value + Units) ;
Total_ml.getLabel().getCaption().getFont().setName("Lucida Sans Unicode");
Total_ml.getLineAttributes().setStyle(LineStyle.SOLID_LITERAL);
Total_ml.getLineAttributes().setThickness(8);
//Sets Marker Lable Anchor Position
Total_ml.setLabelAnchor(Anchor.SOUTH_WEST_LITERAL);
}
Find more posts tagged with
Comments
mwilliams
The format code "#,###.00" should be used if you want the comma to show. The format should change based on locale.