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)
Birt pie chart localization via URL parameter
Nikhila
How can i localize birt report pie chart with different resource files based on _locale parameter from URL?
Find more posts tagged with
Comments
Clement Wong
<p>Can you let us know what part of the pie chart you would like to localize? Or a specific use case/example?</p>
<p> </p>
<p>There is a DevShare that shows the use of localization @ <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/files/file/681-localization-of-birt-reports/'>http://developer.actuate.com/community/forum/index.php?/files/file/681-localization-of-birt-reports/</a></p>
;
<p> </p>
<p>Further documentation (this one is from iHub3) is @ <a data-ipb='nomediaparse' href='
http://developer.actuate.com/be/documentation/ihub3/help/adg/adg44/index.html'>http://developer.actuate.com/be/documentation/ihub3/help/adg/adg44/index.html</a></p>
;
Nikhila
<p>Hi,</p>
<p> </p>
<p> I have two resource files one for English and another for Hindi. Based on the UI parameter(en/hi) i want to localize my pie charts(title,axis,label and legend).I refereed the above links which you have provided.But i want to localized based on the URL parameter. How can i do?</p>
Clement Wong
<p>You can use the <strong>__locale</strong> parameter. Example <span style="font-family:'courier new', courier, monospace;">&__locale=en_US</span>.</p>
<p> </p>
<p><a data-ipb='nomediaparse' href='
https://wiki.eclipse.org/BIRT/FAQ/Internationalization#Q:_Can_the_user_specify_the_report_locale_when_running_the_report.3F'>https://wiki.eclipse.org/BIRT/FAQ/Internationalization#Q:_Can_the_user_specify_the_report_locale_when_running_the_report.3F</a></p>
;
Nikhila
<p>Thank you for your quick reply.
Clement Wong
<p>I see that you use<strong><span style="font-family:'courier new', courier, monospace;"> new Locale(rc.getParameterValue("Locale"))</span></strong>, did you know that you can use <span style="font-family:'courier new', courier, monospace;">icsc.getExternalContext().getScriptable().getLocale()</span>or in your case<span style="font-family:'courier new', courier, monospace;"> rc.getLocale()</span> ?<br>
</p>
<p>Since you didn't attach a sample .rptdesign and data, I'm not sure how your Data Set columns data types and pie chart's Category Definition is defined. You should <strong>not </strong>need to overwrite an event to have the legend display with the date/time in the user's specified locale <em>if </em>you have the Category Definition with Grouping Enabled, the Type set to DateTime, and the Unit set to (in your case) Months.</p>
<p> </p>
<p>Please attach your sample so that we can look into this further. </p>
<p> </p>
<p>For reference, if you wanted to change the legend values, in the beforeDrawLegendItem event, you can set the legend's label via</p>
<p><span style="font-family:'courier new', courier, monospace;">lerh.getLabel().getCaption().setValue() </span>, and get the current legend's label via <span style="font-family:'courier new', courier, monospace;">lerh.getLabel().getCaption().getValue()</span></p>
<p> </p>
<p>To change the series values, in the beforeDrawDataPointLabel event, you can set the current value via <span style="font-family:'courier new', courier, monospace;">label.getCaption().setValue()</span> and get the value via <span style="font-family:'courier new', courier, monospace;">label.getCaption().getValue()</span> .</p>
Nikhila
<p><span style="color:rgb(0,0,0);font-family:'courier new', courier, monospace;font-size:medium;">rc.getLocale() returns current system locale. But i want to change locale value based on the user selected value from UI. so that i have used </span><strong><span style="font-family:'courier new', courier, monospace;">rc.getParameterValue("Locale").</span></strong></p>
<p><strong><span style="font-family:'courier new', courier, monospace;">I have resolved series values by the following code. But i am not sure is this is the right way.</span></strong></p>
<p> </p>
<p> </p>
<div>importPackage (Packages.java.text);</div>
<div>importPackage (Packages.java.util);</div>
<div>nf = NumberFormat.getInstance(new Locale("hi","IN"));</div>
<div>var val = nf.parse(label.getCaption().getValue());</div>
<div>label.getCaption().setValue((nf.format(val))); </div>
Clement Wong
<p>If you use the Viewer, the URL parameter __locale (as previous mentioned in <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/36700-birt-pie-chart-localization-via-url-parameter/?p=136635'>post
#4</a>) allows you to change the locale of the report. And using getLocale() will return the value passed in from __locale.</p>
Nikhila
<p>Thanks for your time it worked for me
</p>