Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Stacked BarChar - change one serie to Line
Stacked BarChar - change one serie to Line [message #956292] Wed, 24 October 2012 11:44 Go to next message
Jaroslav Uher is currently offline Jaroslav UherFriend
Messages: 17
Registered: July 2009
Junior Member
I need to use stacked bar chart, where series are generated dynamically
by grouping. One of series (identified by name) should be displayed as
line. How to do it?

I found only switching stack/unstack or visibility in beforeDrawSeries:

var seriesID = series.getSeriesIdentifier();
if (seriesID == "total") {
series.setStacked(false); <<
}

regards
Jaroslav
Re: Stacked BarChar - change one serie to Line [message #958180 is a reply to message #956292] Thu, 25 October 2012 20:37 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

This post shows how you can modify a series's type, in script, but it's in the beforeFactory script, which would be before your grouping took place. I'll have to look at this a little closer to see if the series type can be changed in the chart's onRender script.

BIRT Exchange - DevShare


Michael

Developer Evangelist, Silanis

[Updated on: Fri, 26 October 2012 02:52]

Report message to a moderator

Re: Stacked BarChar - change one serie to Line [message #958386 is a reply to message #958180] Fri, 26 October 2012 00:38 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

Looks like you might be able to get this to happen, in the beforeGeneration script. With the stacked bar with optional grouping, I wasn't able to create my own lineSeries and put it in there, in some quick testing. I was able to create a hidden line series and steal one line from the hidden series definition and put it in the stacked bar visible series definition, however, it had to be a stacked series, which might not work for you.

Edit:

If you create a second identical series, in your chart only make it a line chart and unstack it. You can simply step through your series and hide the stacked bar and then step through the next series and hide all lines except the one you want to show, with a script like this:

function beforeGeneration( chart, icsc )
{
xAxis = chart.getAxes().get(0);
yAxis = xAxis.getAssociatedAxes().get(0);
sd1 = yAxis.getSeriesDefinitions().get(0);
sd2 = yAxis.getSeriesDefinitions().get(1);

for(i=0;i<sd1.getSeries().size();i++){

if(sd1.getSeries().get(i).getSeriesIdentifier() == "Series 1"){
sd1.getSeries().get(i).setVisible(true);
}
else if(sd1.getSeries().get(i).getSeriesIdentifier() == "total"){
sd1.getSeries().get(i).setVisible(false);
}
else{
sd1.getSeries().get(i).setVisible(true);
}
}
for(i=0;i<sd2.getSeries().size();i++){

if(sd2.getSeries().get(i).getSeriesIdentifier() == "Series 2"){
sd2.getSeries().get(i).setVisible(true);
}
else if(sd2.getSeries().get(i).getSeriesIdentifier() == "total"){
sd2.getSeries().get(i).setVisible(true);
}
else{
sd2.getSeries().get(i).setVisible(false);
}
}
}


Michael

Developer Evangelist, Silanis

[Updated on: Fri, 26 October 2012 01:28]

Report message to a moderator

Re: Stacked BarChar - change one serie to Line [message #963189 is a reply to message #958386] Mon, 29 October 2012 16:29 Go to previous messageGo to next message
Jaroslav Uher is currently offline Jaroslav UherFriend
Messages: 17
Registered: July 2009
Junior Member
Use identical data for bar/stacked and line/unstacked series and change visibility was my first idea. I used similar code in beforeDrawSeries and change visibility by serie name and stack type.

	if (series.isStacked()) {
		// bar series - hide total
        if (seriesID == "total") series.setVisible(false);
	} else {
		// line - only total is visible
        if (seriesID != "total") series.setVisible(false);
	}



I have problem with same change of a legend entries. How can I reorganize entries - same way as series?

Picture show my problem if I use beforeDrawLegendItem and afterDrawLegendItem:
1) some of legend entries not in list (too much entries when doubled) = my line/total is not visible
2) after hiding entries there is unusual empty space
3) if legend entries ar organized in more columns I am lost with moving to right place

regards
Re: Stacked BarChar - change one serie to Line [message #964539 is a reply to message #963189] Tue, 30 October 2012 15:57 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

I went a little bit further, in my script above and actually removed the unwanted series, rather than just hiding them. This should take care of your legend issues. Let me know your version and I can attach an example report.

Michael

Developer Evangelist, Silanis
Re: Stacked BarChar - change one serie to Line [message #965398 is a reply to message #964539] Wed, 31 October 2012 07:48 Go to previous messageGo to next message
Jaroslav Uher is currently offline Jaroslav UherFriend
Messages: 17
Registered: July 2009
Junior Member
I use BIRT 4.2.1, chart version is 2.5.3
Re: Stacked BarChar - change one serie to Line [message #968722 is a reply to message #956292] Fri, 02 November 2012 17:53 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

Sorry for the delay. I upgraded computers and had to get everything transferred over. Take a look at this example.



Michael

Developer Evangelist, Silanis
Re: Stacked BarChar - change one serie to Line [message #986968 is a reply to message #968722] Thu, 22 November 2012 15:28 Go to previous messageGo to next message
Jaroslav Uher is currently offline Jaroslav UherFriend
Messages: 17
Registered: July 2009
Junior Member
Michael, your example is perfect - it shows exactly what I needed

[Updated on: Thu, 22 November 2012 15:28]

Report message to a moderator

Re: Stacked BarChar - change one serie to Line [message #987159 is a reply to message #986968] Fri, 23 November 2012 21:56 Go to previous message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

Great! Glad to help!

Michael

Developer Evangelist, Silanis
Previous Topic:Call XLS Tribix Emitter from Php Java Bridge
Next Topic:How to summarize rows in a Data Set without using the Data Cude
Goto Forum:
  


Current Time: Thu Apr 25 00:32:53 GMT 2024

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

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

Back to the top