Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Dynamic labels on Charts
hallj05
<p>Hey</p><p> </p><p>We are using BIRT 4.2.2</p><p> </p><p>I'm trying to do localization of our reports using something other than the locale. </p><p> </p><p>We are using the locale to do the formatting of the Numbers/Currency/Dates. But to do the different languages for the reports we are using an excel doc as a data set which contains the different languages.</p><p> </p> <p>Example of the excel file</p><p> </p><p>ID Field 1 </p><p>en Hello</p><p>fr Bonjour</p><p>es Hola</p><p> </p><p>Is there a way to make the labels/legend of the reports to be able to change into the values in the data set? Since it seems like they are only stored in text only. Maybe this is possible via scripting?</p><p> </p><p>Thanks for any help!</p>
Find more posts tagged with
Comments
mwilliams
<p>You could definitely do it via scripting. You could filter the excel result set by locale so you only have one row, then grab the values from this dataSet and store them in an array of some sort and then set the values of your legend/labels using script.</p>
hallj05
<p>Would this work for in charts? Just noticed that I only mentioned that in the title and not anywhere in my first post.</p><p> </p><p>Since I've got it working by using a data set for all the labels outside of the charts, but on the charts it doesn't allow use of the data sets as it does in a data field.</p><p> </p><p>If so how would it look like in the scripts? I don't have much experience in the scripting side. Are there any examples of doing something like this posted anywhere?</p><p> </p><p>Thanks for the help, glad to see that it seems like it's going to be possible since I have all the other parts working and it figures that it would be the last part I try to get to work that would cause some issues.</p>
mwilliams
<p>You'd just need to store the translation values into an array in your dataSet's onFetch script, then pass this array through a persistentGlobalVariable to your chart script and use the values in the array to translate your label values in your chart script. I can see if I can set something up. I'll try in the morning.
</p>
hallj05
<p>Thanks, I think that I have got how it works after reading that.</p><p> </p><p>Thanks for the help, if I run into any issues when putting it into the reports I will post again on this topic but for now I think everything is good
</p>
mwilliams
Not a problem. Definitely let me know if you run into issues.
hallj05
<p>So I've run into an issue.</p><p> </p><p>It seems the way I have it set up at the moment that the script for the chart is running before the dataset script.</p><p> </p><p>Here is what I have in each script.</p><p> </p><p>DataSet onFetch</p><p>reportContext.setPersistentGlobalVariable('xaxisValue','test');</p><p> </p><p>Chart onRender</p><p>function beforeGeneration( chart, icsc )
{
xAxis = chart.getBaseAxes()[0];
xAxis.getTitle().getCaption().setValue(icsc.getExternalContext().getScriptable().getPersistentGlobalVariable('xaxisValue'));
}</p><p> </p><p> </p><p>Which if I move the reportContext.setPersistentGlobalVariable('xaxisValue','test'); part into the initialize script of the report, then the label on the chart changes. Which is why it seems that the dataset script is happening after the chart script.</p><p> </p><p>Currently just setting the value as a string to test the global variable.</p><p> </p><p> </p><p>Edit: So it seems that this is because my excel file is not the dataset that the chart is using. Since if I put the reportContext.setPersistentGlobalVariable('xaxisValue','test'); into the other dataset then it works. But this won't help with what I need since I need the values from the excel dataset. Seems strange that it only takes the global variable from that one dataset and not all of them.</p><p> </p><p>Edit2: I got it working. I had to make it use the excel dataset somewhere on the report, which makes sense seeing as otherwise it would not set the global variable. So it's all working now.</p>