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)
How to change dynamically the Labels of a Flash Chart
xalperte
I'm trying to generate dynamically (scripting) the labels of a Flash Chart, but I'm not finding a way to do it.<br />
<br />
In the normal charts (not flash charts) it seems there is a special callback function to accomplish this: <br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>function beforeDrawAxisLabel( axis, label, context )</pre>
<br />
But I cannot find a similar function for the flash charts.<br />
<br />
Anyone know how to do it?<br />
<br />
Thanks in advance
Find more posts tagged with
Comments
mwilliams
Is this for editing the x-axis values? If so, you can edit the x-axis series values in the afterDataSetFilled by checking for the series identifier, "". Let me know more about what you're trying to do and I'll try to provide an example.
xalperte
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="109151" data-time="1347312230" data-date="10 September 2012 - 02:23 PM"><p>
Is this for editing the x-axis values? If so, you can edit the x-axis series values in the afterDataSetFilled by checking for the series identifier, "". Let me know more about what you're trying to do and I'll try to provide an example.<br /></p></blockquote>
<br />
Hi Michael, thanks for your response!<br />
<br />
You can find attached an example of the chart I'm trying to generate.<br />
<br />
One of the parameters of the report is the kind of grouping we want to use to show the results in the chart, selecting one of the following values: Annual, Quarter, Month, Week. <br />
<br />
We have defined the following script to set the correct grouping configuration based on the report parameter value:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>/**
* Called while the start of generating flash chart's XML data.
*
*
@param
flashChart
* FlashChart
*
@param
fcsc
* FlashChartScriptContext
*/
function beforeRendering( flashChart, fcsc )
{
var analysisType = fcsc.getExternalContext().getScriptable().getParameterValue("analysisType");
importPackage( Packages.org.eclipse.birt.chart.model.attribute.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.data.impl );
var axis = flashChart.getChart().getBaseAxes()[0];
var seriesDef = axis.getSeriesDefinitions();
for( o = 0; o < seriesDef.length; o++ ) {
var grouping = seriesDef[o].getGrouping();
if( analysisType == "year" ) {
grouping.setGroupingUnit(GroupingUnitType.YEARS_LITERAL );
}
if( analysisType == "quarter" ) {
grouping.setGroupingUnit(GroupingUnitType.QUARTERS_LITERAL );
}
if( analysisType == "month" ) {
grouping.setGroupingUnit(GroupingUnitType.MONTHS_LITERAL);
}
if( analysisType == "week" ) {
grouping.setGroupingUnit(GroupingUnitType.WEEKS_LITERAL );
}
if( analysisType == "day" ) {
grouping.setGroupingUnit(GroupingUnitType.DAYS_LITERAL );
}
}
}</pre>
<br />
Using the same approach (scripting), we need to configure the text of the labels in the X-axis to show years ("yyyy"), quarters ("yyyy Q"??), months ("yyyy MM") or weeks ("yyyy MM WW"), depending on the value selected for the report parameter.<br />
<br />
Thanks again!
mwilliams
Does the script above for setting the grouping type work for you? It's not working for me.