Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » How can you reorder the series of a line chart?
How can you reorder the series of a line chart? [message #653666] Thu, 10 February 2011 15:56 Go to next message
Mike Wulkan is currently offline Mike WulkanFriend
Messages: 147
Registered: July 2009
Senior Member
I have a line chart with 7 series (no comments please on the usability of said chart Wink )

I would like to specify the a different order for these series other than the order that I added them to the chart as the order contains some semantic meaning and would make more sense for the legend to list the series in that order.

How can I do this in the GUI without having to recreate the series definition?
Re: How can you reorder the series of a line chart? [message #653710 is a reply to message #653666] Thu, 10 February 2011 18:39 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Mike,

Select the X-Axis item in the third tab of the wizard. There is a
reverse categories checkbox. Does checking it do what you want? If not
you can alter the legend order in script. Let me know if you need an
example.

Jason

On 2/10/2011 10:56 AM, Mike Wulkan wrote:
> I have a line chart with 7 series (no comments please on the usability
> of said chart ;) )
>
> I would like to specify the a different order for these series other
> than the order that I added them to the chart as the order contains some
> semantic meaning and would make more sense for the legend to list the
> series in that order.
>
> How can I do this in the GUI without having to recreate the series
> definition?
Re: How can you reorder the series of a line chart? [message #653714 is a reply to message #653710] Thu, 10 February 2011 19:31 Go to previous messageGo to next message
Mike Wulkan is currently offline Mike WulkanFriend
Messages: 147
Registered: July 2009
Senior Member
I tried that but it didn't work (at least not for me). It did show the legend changing in the preview, but not when I actually ran the report.

I in the end I would like to directly control the order that the items appear. An example would be much appreciated.
Re: How can you reorder the series of a line chart? [message #653725 is a reply to message #653714] Thu, 10 February 2011 20:24 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Mike,

Here is one way to do it (using a beforeRendering script):

function beforeRendering( gcs, icsc )
{
//Script reverses chart legend order
importPackage(Packages.org.eclipse.birt.chart.computation);
importPackage(Packages.java.util);
importPackage(Packages.java.lang);


var llh = gcs.getRunTimeContext().getLegendLayoutHints();
//current legend
var liha = llh.getLegendItemHints( );
//new legend construct
var nliha = java.lang.reflect.Array.newInstance(LegendItemHints,
(liha.length));

if ( liha.length > 1 ){
for( idx=0; idx < liha.length; idx++ ){

var tli = liha[idx];
var oldpos = tli.getIndex();
var newpos = (liha.length-1)-idx;

var ntli = liha[newpos];

//valid legend entry
if( tli.getType() == LegendItemHints.Type.LG_ENTRY){
//create a new legend item using the the new items values
var lih = LegendItemHints.newEntry( ntli.getItemText(),
ntli.getValueText(), ntli.getSeriesDefinition(), ntli.getSeries(),
ntli.getIndex() );
lih.top(tli.getTop());
lih.left(tli.getLeft());
nliha[idx]=lih;
}else{
//separator
nliha[idx]=liha[idx];
}

}
}
//Create a new copy of the legend layout hints
var nllh = new LegendLayoutHints(
llh.getLegendSize(),llh.getTitleSize(),null,
llh.isMinSliceApplied(),llh.getMinSliceText(),
nliha );
//Update before rendering
gcs.getRunTimeContext().setLegendLayoutHints(nllh);

}

Jason

On 2/10/2011 2:31 PM, Mike Wulkan wrote:
> I tried that but it didn't work (at least not for me). It did show the
> legend changing in the preview, but not when I actually ran the report.
>
> I in the end I would like to directly control the order that the items
> appear. An example would be much appreciated.
Previous Topic:Pie Chart Legend value ordering
Next Topic:Control the "speed" of a gradient?
Goto Forum:
  


Current Time: Sat Apr 20 00:04:44 GMT 2024

Powered by FUDForum. Page generated in 0.03205 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top