Change the legend order
Comments
-
<p>You can modify the legendIndex of the series options to change the order of the items in the legend of an HTML5 chart.</p>
<p>For Example:</p>
<pre class="_prettyXprint _lang-js">
beforeDrawSeries: function(series, seriesOptions, chart, seriesIndex)
{
if(seriesIndex == 0){
seriesOptions.legendIndex = 2;
}
},
</pre>
<p>Take a look at the attached modified version of your sample report with this code in place.</p>
Warning No formatter is installed for the format ipb0 -
<p>I'm not sure but I think I understand something.</p>
<p> </p>
<p>In this code we use serie, so serie 1 and serie 2 for exemple.</p>
<p> </p>
<p>"seriesIndex == 0" is for the serie 1 so ?</p>
<p> </p>
<p>But here I don't use a serie so I don't know if this has an influence. I use the "optional grouping" the seriesIndex can be used in this ?</p>
<p> </p>
<p>I try different way but nothing work</p>
0 -
<p>Yes, in the modified sample report I attached in my previous the legend displays the 2012 series above the 2011 series.</p>
<p> </p>
<p>When you use option grouping on the y series, it will create a separate series for each grouping dynamically when the chart is rendered. Therefore, when the chart is rendering there will be a separate series and series index created for each grouping.</p>
<p> </p>
<p>The legend index, like the series index, is the index associated with each item in the legend. Since your sample has 2 series, by default, the legend index for series 1 will be 0 and the legend index for series 2 will be 1.</p>
<p> </p>
<p>What I have done is to simply change the legend index of the first series to 2 which will place it after the second series in the legend index list causing it to display below the second series' legend entry.</p>
Warning No formatter is installed for the format ipb0 -
<p>Hmm that is strange as I just downloaded the report I attached myself and ran it without modifications and I get the correct result.</p>
<p>See the attached screenshot for reference.</p>
<p> </p>
<p>What version of the designer are you using?</p>
Warning No formatter is installed for the format ipb0 -
<p>I use the last version 4.4 birt designer pro. <br>
</p>
<p>That don't work with my professionnal computer (and IE 10)</p>
<p>
I try with my personnal computer, with same version of Birt designer pro but google chrome and that work. </p>
<p> </p>
<p>I don't know if this issu is due to IE or my professionnal computer.</p>
0 -
<p>I do not believe it is specific to IE 10 itself.</p>
<p>I just tested with IE 10 on my machine and it worked without issue. See the attached screenshot for reference.</p>
<p> </p>
<p>This makes me believe it is something specific to the machine.</p>
<p>What are your browser security settings like on the machine with the issue?</p>
<p>Do you get any javascript errors on the page?</p>
<p> </p>
<p>My guess would be that something is blocking this client side code from running.</p>
Warning No formatter is installed for the format ipb0 -
<p>Really appreciate your answer and example. Thanks!</p>
0 -
Thank you @Grimmr74
It looks like this conversation was migrated from a previous system, and unfortunately the attachment was not included in the process. We do not have the original attachment available, nor the attachment in @JEFreeman 's comment. Our apologies for this inconvenience.
0 -
Hi, my BIRT designer version is 4.9.0, and the parameters in beforeDrawSeries have changed. How to control legend order in this function now. Could anyone please help me with this problem?
/** * Called before rendering Series. * * @param series * Series * @param isr * ISeriesRenderer * @param icsc * IChartScriptContext */ function beforeDrawSeries( series, isr, icsc ) { }
0 -
I solve the problem by swapping the left and right item locations, the order will be reversed. It works fine for me.
function beforeRendering( gcs, icsc ) { var legendItems = gcs.getRunTimeContext().getLegendLayoutHints().getLegendItemHints( ); for( i=0; i < legendItems.length / 2; i++ ){ // left item and right item var leftItem = legendItems[i]; var rightItem = legendItems[legendItems.length-1-i]; //swap their location(top, left) top = leftItem.getTop(); left = leftItem.getLeft(); leftItem.top(rightItem.getTop()); leftItem.left(rightItem.getLeft()); rightItem.top(top); rightItem.left(left); } }
0
Categories
- All Categories
- 123 Developer Announcements
- 54 Articles
- 153 General Questions
- 148 Thrust Services
- 57 Developer Hackathon
- 37 Thrust Studio
- 20.6K Analytics
- 4.2K AppWorks
- 9K Extended ECM
- 918 Core Messaging
- 84 Digital Asset Management
- 9.4K Documentum
- 32 eDOCS
- 190 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 10 XM Fax
- Follow Categories