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)
Localization of the datetime in the chart
XFabien
Hello,
I want to change the localization to 'France' instead of the 'UK' by the default.
So I added the script below in 'beforeFactory' of the report :
reportContext.getDesignHandle().setStringProperty("locale", "fr_FR");
It works very well with BIRT2.6 but ont with BIRT2.5.1.
With BIRT2.5.1, the seperator of the numbers works very well but the format datetime in the chart doesn't work.
So, my question is that how should I do to make it work with the BIRT2.5.1.
I hope someone knows how to do it and I appreciate your help.
Thanks very much.
Yao
Find more posts tagged with
Comments
mwilliams
Can you attach a report that uses the sample database that shows your issue? If I make a simple chart in 2.5.1 with date as the x-axis label, the format changes when I set the locale in the beforeFactory. Maybe I'm not understanding fully.
XFabien
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="94009" data-time="1326400908" data-date="12 January 2012 - 01:41 PM"><p>
Can you attach a report that uses the sample database that shows your issue? If I make a simple chart in 2.5.1 with date as the x-axis label, the format changes when I set the locale in the beforeFactory. Maybe I'm not understanding fully.<br /></p></blockquote>
<br />
<br />
Hello Michael,<br />
<br />
I add an exemple here, you can test it that it doesn't work in 2.5.1 but it work very well in 2.6.2.<br />
<br />
Thanks for the help.<br />
mwilliams
If you remove the format code in the chart, it works in 2.5.1, so it appears that the format code is the catch here. I'll see if I can get around it. I'll post the example in here, if I do.
mwilliams
Ok, try this script in your chart:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeDrawAxisLabel( axis, label, icsc )
{
importPackage (Packages.java.text);
importPackage (Packages.java.util);
paramValue = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("lang");
if (axis.isCategoryAxis()){
currentLabel = label.getCaption().getValue();
df = new SimpleDateFormat("MMM/yy");
temp = df.parse(currentLabel);
if (paramValue == "fr"){
df1 = new SimpleDateFormat("MMM/yy",Locale.FRENCH);
}
else{
df1 = new SimpleDateFormat("MMM/yy",Locale.UK);
}
newLabel = df1.format(temp);
label.getCaption().setValue(newLabel)
}
}
</pre>
<br />
I pass the parameter in through a persistent global variable that is set in the beforeFactory method.<br />
<br />
Hope this helps until you can upgrade.