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)
Forcing BIRT to use specific sereis palette entry for a specific series type
josephnina
Hi
I have a stacked area chart containing three types plotted as a monthly chart(12 months on x axis).
1) Yes - Should be indicated with a green pattern
2) No - Should be indicated with a red pattern
3) N/A - Should be indicated with a grey pattern.
I have defined these three patterns using Series Palette / Embedded Image.
I use Optional Y Series grouping to spilt the types.
Currently I am letting BIRT pick up the patterns to be used automatically from the Series Palette.
Problem with this approach is BIRT starts mixing up the color/pattern as soon as a particular type is not present for the time period(For eg, if only types No and N/A are present, No is in green and N/A is in red).
Thinking of scripting it such that I can force BIRT to select the pattern to be used. I saw examples with forcing a colorDefinition for a series type but could not figure out how to force a particular embeddable image pattern as defined in the series palette as the pattern to be used for a series Type.
Please help.
Thanks and Regards
Joseph
Find more posts tagged with
Comments
josephnina
<p>Got a similar scenario for a bar chart. Was able to clone the palette defintions over to a temp variable and use the required palette entry using the below logic.</p><p>In case a type is missing, the chart will still be able to use the correct palette entry for the next type.</p><p> </p><p><strong class='bbc'>function</strong> beforeGeneration( chart, icsc )</p><p>{</p><p> </p><p> </p><p><strong class='bbc'>var</strong> yAxisSecondary = xAxis.getAssociatedAxes().get(1); //Secondary Bar Chart defined on second axis You may have to change this to 0 its ifs a primary series.</p><p><strong class='bbc'>var</strong> ySeriesDefBarChartVolume= yAxisSecondary.getSeriesDefinitions().get(0); //Bar Chart</p><p> </p><p> </p><p>//Setting porperties on Secondary Axis (Volume)</p><p><strong class='bbc'>var</strong> ySeries = ySeriesDefBarChartVolume.getRunTimeSeries();</p><p><strong class='bbc'>var</strong> numberofrunseries = ySeries.size(); </p><p>//loop thru all of the series</p><p> </p><p> </p><p>temp = ySeriesDefBarChartVolume.getSeriesPalette().getEntries().clone(); //Copying to a temp variable</p><p>ySeriesDefBarChartVolume.getSeriesPalette().getEntries().clear(); //Clearing palette</p><p> </p><p><strong class='bbc'>for</strong> (<strong class='bbc'>var</strong> i = 0; i < numberofrunseries; i++) { </p><p><strong class='bbc'>if</strong> ( ySeries.get(i).getSeriesIdentifier() == 'A' ) {</p><p>ySeries.get(i).setTranslucent(<strong class='bbc'>true</strong>); </p><p> </p><p>ySeriesDefBarChartVolume.getSeriesPalette().getEntries().add(temp.get(0)); //If type A exisits, use palette entry 0 for this type</p><p>}</p><p> </p><p><strong class='bbc'>if</strong> ( ySeries.get(i).getSeriesIdentifier() == 'B' ) {</p><p>ySeries.get(i).setTranslucent(<strong class='bbc'>true</strong>); </p><p>ySeriesDefBarChartVolume.getSeriesPalette().getEntries().add(temp.get(1));</p><p> </p><p> </p><p> </p><p> </p><p>}</p><p> </p><p><strong class='bbc'>if</strong> ( ySeries.get(i).getSeriesIdentifier() == 'C' ) {</p><p>ySeries.get(i).setTranslucent(<strong class='bbc'>true</strong>); </p><p>ySeriesDefBarChartVolume.getSeriesPalette().getEntries().add(temp.get(2));</p><p>}</p><p>} </p><p>}</p>
mwilliams
<p>Glad you found a solution! Let us know whenever you have questions!
</p>