Stacked Bar Series - How to reorder the legend
<p>I have a stacked bar chart with five series (A, B, C, D, E).</p>
<p>The chart is drawn as I like to have it: A is at the bottom and E is stacked at the top.<br>
But in the Legend A is at the top and E is listed as last.</p>
<p>How can I change the legend order without changing the stack order?</p>
<p>The chart is drawn as I like to have it: A is at the bottom and E is stacked at the top.<br>
But in the Legend A is at the top and E is listed as last.</p>
<p>How can I change the legend order without changing the stack order?</p>
0
Comments
-
<p>Hi,</p>
<p> </p>
<p>Which version of BIRT are you running? What type of chart output? SVG? HTML5?</p>
<p> </p>
<p>I have tried both BIRT Open Source and BIRT Commercial and got correct results as show in this screen shot:</p>
<p> </p>
<p>Warning No formatter is installed for the format ipb0 -
<p>Hi,</p>
<p> </p>
<p>Interesting... It appears the legend is displayed in reverse order only when the stacked chart also includes series displayed as lines.</p>
<p> </p>
<p>Anyhow, with some chart scripting, I was able to reverse the order. I found the script from an old post on eclipse.org, and applied it "as is".</p>
<p> </p>
<p>Since I cannot run your report, I am sending you a sample report built with Classic Models. You can copy and paste the chart scripting from my example to your report; it should work.</p>
<p> </p>
<p>Hope this helps,</p>
<p> </p>
<p>P.</p>
Warning No formatter is installed for the format ipb0 -
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