Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Sum of each bar in a bar chart(Display the sum of each bar items above each bar in bar chart)
Sum of each bar in a bar chart [message #1031897] Tue, 02 April 2013 10:46 Go to next message
taha ziat is currently offline taha ziatFriend
Messages: 4
Registered: April 2013
Location: Morocco
Junior Member

Hi all birt users and developpers Smile

I use birt version 2.3.2 for maximo TSRM version 7.1.1.5.

In a bar chart I want calculate and display the sum of each bar above each bar like this :
index.php/fa/14206/0/

Have you any idea?

Isn't javascript useful to do that? how if so?

Please help!!
Re: Sum of each bar in a bar chart [message #1032249 is a reply to message #1031897] Tue, 02 April 2013 19:22 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1687
Registered: July 2009
Senior Member

Take a look at this old post. There's an example showing how you can show the total of a stacked bar:

http://www.eclipse.org/forums/index.php/mv/msg/262316/758148/


Michael

Add interactivity, scheduling, sharing, live Excel export, and JS integration to your BIRT app with the new, free BIRT server, BIRT iHub F-Type.
Re: Sum of each bar in a bar chart [message #1033754 is a reply to message #1032249] Thu, 04 April 2013 15:48 Go to previous messageGo to next message
taha ziat is currently offline taha ziatFriend
Messages: 4
Registered: April 2013
Location: Morocco
Junior Member

Thank you Michael Williams for you response Smile

The solution in this link didn't work for me (or purhaps I didn't know how to adapt the script for my chart), but I got to do it by the following method (I know it's not a smart way to do it, it's the hard working way instead ):
1. Modify the query by adding a piece of sql which gives the sum of the each bar
2. Change the chart by adding another linear axe (see figure)
index.php/fa/14247/0/

the problem that I encounter later is that I have two legends, one for the bars (the right legend) un one for the curve that shows the sum (unneeded one). and by using the script bilow I was able to disapear the unneeded legend items but their space is still allocated (see figures) :
index.php/fa/14248/0/
index.php/fa/14249/0/

/**
 * Called before drawing the legend item.
 * 
 * @param lerh
 * 			  LegendEntryRenderingHints
 * @param bounds
 * 			  Bounds
 * @param icsc
 * 			  IChartScriptContext
 * @since Version 2.2.0
 */
legendItems = new Array();
index = 0;
function beforeDrawLegendItem( lerh, bounds, icsc )
{
	var val1 = lerh.getLabel().getCaption().getValue();
	var flag = 0 ;
	index = index + 1 ;
	for ( i=0; i<index ; i=i+1)
    {
		if(legendItems[i] == val1)
		{
			flag = 1;
			break;
		}
	}
	if(flag == 0)
	{
		legendItems[index] = val1 ;
		bounds.setHeight(0);
		bounds.setWidth(0);
		lerh.getLabel().getCaption().setValue("");
	}
	if(val1.compareToIgnoreCase("") == 0 || val1.compareToIgnoreCase("0") == 0 || val1.compareToIgnoreCase("Series 2") == 0)
	{
		bounds.setHeight(0);
		bounds.setWidth(0);
		lerh.getLabel().getCaption().setValue("");
	}
}


Have you any idea how to hide one legend and let the others in the same chart?

Thank you in advance Smile
Re: Sum of each bar in a bar chart [message #1034192 is a reply to message #1033754] Fri, 05 April 2013 05:54 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1687
Registered: July 2009
Senior Member

If you switched the order of the series to make the order switch in the legend, the blank might not be a big deal. Another option could be to create a new BarSeries and add it to your chart. You could set the value to be very small and make the label appear outside the bar. Once you've done this, you could replace the value in the label with the correct value.

Michael

Add interactivity, scheduling, sharing, live Excel export, and JS integration to your BIRT app with the new, free BIRT server, BIRT iHub F-Type.
Re: Sum of each bar in a bar chart [message #1034573 is a reply to message #1034192] Fri, 05 April 2013 15:53 Go to previous messageGo to next message
taha ziat is currently offline taha ziatFriend
Messages: 4
Registered: April 2013
Location: Morocco
Junior Member

Thank you very much Michael Williams for your help, I'll try this two ideas and let you know about it.
Re: Sum of each bar in a bar chart [message #1034585 is a reply to message #1034573] Fri, 05 April 2013 16:14 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1687
Registered: July 2009
Senior Member

Sounds good. I can make a simple/rough example of adding a bar series in the beforeGeneration script of the chart, if you need. Just let me know.

Michael

Add interactivity, scheduling, sharing, live Excel export, and JS integration to your BIRT app with the new, free BIRT server, BIRT iHub F-Type.
Re: Sum of each bar in a bar chart [message #1058603 is a reply to message #1031897] Tue, 14 May 2013 14:24 Go to previous message
taha ziat is currently offline taha ziatFriend
Messages: 4
Registered: April 2013
Location: Morocco
Junior Member

Hi all,

I for the last problem I had (unneeded legend), I changed the markers for the new line series to "Box" and I aply the a script to disapear the bar series legend, so , the unneeded legend became the used one and I desapear the right one.

see atachment

Thank you all for your help Smile
Previous Topic:CrossTab Cell formating
Next Topic:Report Key/Parameter/variable?
Goto Forum:
  


Current Time: Sat Dec 20 14:30:47 GMT 2014

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

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