|
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 |
|
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 #653725 is a reply to message #653714] |
Thu, 10 February 2011 20:24 |
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.03898 seconds