Sum of each bar in a bar chart [message #1031897] |
Tue, 02 April 2013 10:46  |
|
Hi all birt users and developpers
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 :

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 #1033754 is a reply to message #1032249] |
Thu, 04 April 2013 15:48   |
|
Thank you Michael Williams for you response 
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)

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) :


/**
* 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
|
|
|
Re: Sum of each bar in a bar chart [message #1034192 is a reply to message #1033754] |
Fri, 05 April 2013 05:54   |
|
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
Developer Evangelist, Silanis
|
|
|
|
|
Re: Sum of each bar in a bar chart [message #1058603 is a reply to message #1031897] |
Tue, 14 May 2013 14:24  |
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.02808 seconds