Home
Analytics
dynamic label for a chart axis
cheli
hello everyone, I'm new on birt's world.
I need do dynamics the labels of a chart axis. I want to get un axe X whith dates that change dynamically for the parameter "langue". if this parameter is 'français' the dates are the format "dd/MM/yy", but if "langue" is 'english' the format would be "MM/dd/yy" .
The problem is that the format of the date don't change, please i need help.
this is the code of my script.
importPackage(Packages.java.text);
importPackage(Packages.org.eclipse.birt.chart.model.attribute);
function beforeDrawAxisLabel( axis, label, icsc )
{
var lang = icsc.getExternalContext().getScriptable().getParameterValue( "langue" );
if (lang == "english" )
{
if (axis.getType() == AxisType.DATE_TIME)
{
var actualval = "" + label.getCaption().getValue();
var sdf = new SimpleDateFormat("dd/MM/yy");
var dateval = sdf.parse(actualval);
sdf.applyPattern("MM/dd/yy");
label.getCaption().setValue( sdf.format(dateval) );
axis.setLabel(label);
}
}
}
Thanks:)
Find more posts tagged with
Comments
bhanley
Sounds like you need to be looking at BIRT's localization support. Rather than scripting the date format, BIRT can bind to a specific locale's rules. Before going into a lot of specifics about how this works I thought I would see if I was on the right track. If there is a larger reason you are trying to di this in scripting, that is a different discussion.
cheli
Thanks bhanley,
I haven't any reason for do that with scripting, the only one that i have it is that I am newbi and i don't understand so much BIRT yet and it was the first way that I found to solve my problems, but now i going to search info about support localization.
bhanley
You do not have to search for this stuff alone.
<br />
<br />
Here are some places to look to get going:<br />
<br />
<a class='bbc_url' href='
http://wiki.eclipse.org/BIRT/FAQ/Internationalization'>BIRT/FAQ/Internationalization
- Eclipsepedia</a><br />
<br />
<a class='bbc_url' href='
http://www.eclipse.org/birt/phoenix/intro/intro04.php'>BIRT
Development</a><br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/blog/2008-04-04/using-properties-files-to-localize-birt-reports/'>Using
Properties Files to Localize BIRT Reports » Blog - BIRT Exchange</a><br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/devshare/designing-birt-reports/828-advance-localization-technique/#description'>Advance
Localization Technique - Designs & Code - BIRT Exchange</a>
cheli
Thanks you very much another time ^^