Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » How to set chart series name in javascript
How to set chart series name in javascript [message #741128] Wed, 19 October 2011 07:51 Go to next message
donino donino is currently offline donino doninoFriend
Messages: 183
Registered: July 2011
Senior Member
Hi,

I'm trying to update series name (not legend items: in attached image below i want replace "Series 1" by a runtime value) in a barchart with javascript. I tried beforeDrawSeries event but my code has no effect:
function beforeDrawSeries( series, isr, icsc )
{	series.getLabel().getCaption().setValue('My serie name');
//logInfo('beforedrawseries is fired', icsc);
}


I also tried beforeDrawSeriesTitle but that event seems never firing.
function beforeDrawSeriesTitle( series, label, icsc )
{	label.getCaption().setValue('My serie name');
//	logInfo('beforeDrawSeriesTitle is never fired', icsc);	
}


Please could someone help
Dom

index.php/fa/4415/0/

[Updated on: Wed, 19 October 2011 08:15]

Report message to a moderator

Re: How to set chart series name in javascript [message #741466 is a reply to message #741128] Wed, 19 October 2011 15:03 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Dom

The beforeDrawSeriesTitle is only called for charts without axes. What
are you trying to change in the output of the chart? You can set the
series identifier like:

function beforeGeneration( chart, icsc )
{
importPackage(Packages.java.util);
importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
importPackage(Packages.org.eclipse.birt.chart.model.component.impl);
importPackage(Packages.org.eclipse.birt.chart.model.type.impl);
importPackage(Packages.org.eclipse.birt.chart.model.attribute);

var xAxis = chart.getAxes().get(0);
var yAxis = xAxis.getAssociatedAxes().get(0);
var xSerieDef = xAxis.getSeriesDefinitions().get(0);
var ySerieDef1 = yAxis.getSeriesDefinitions().get(0);



ySerieDef1.getSeries().get(0).setSeriesIdentifier("My Series 1");


}

Jason


On 10/19/2011 3:51 AM, dpardon wrote:
> Hi,
> I'm trying to update series name (not legend items) in a barchart with
> javascript. I tried beforeDrawSeries event but my code has no effect:
> function beforeDrawSeries( series, isr, icsc )
> { series.getLabel().getCaption().setValue('My serie name');
> //logInfo('beforedrawseries is fired', icsc);
> }
>
> I also tried beforeDrawSeriesTitle but that event seems never firing.
> function beforeDrawSeriesTitle( series, label, icsc )
> { label.getCaption().setValue('My serie name');
> // logInfo('beforeDrawSeriesTitle is never fired', icsc);
> }
>
> Please could someone help
> Dom
Re: How to set chart series name in javascript [message #741761 is a reply to message #741466] Wed, 19 October 2011 21:52 Go to previous messageGo to next message
donino donino is currently offline donino doninoFriend
Messages: 183
Registered: July 2011
Senior Member
Thank you for your reponse Jason.

I set up series label to display "value series name" option, just above each bar. So i'm trying to update this series name to replace it by its parameter value.

I tried your code in the attached report and it works, but labels above each bar chart keep using the old series name :/ Very strange. Are these labels generated before the "beforeGeneration" event?
Re: How to set chart series name in javascript [message #742510 is a reply to message #741761] Thu, 20 October 2011 14:58 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

If you change the code a bit and move it to the beforeDataSetFilled
script it should work:

function beforeDataSetFilled( series, idsp, icsc )
{
var chart = icsc.getChartInstance();

importPackage(Packages.java.util);
importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
importPackage(Packages.org.eclipse.birt.chart.model.component.impl);
importPackage(Packages.org.eclipse.birt.chart.model.type.impl);
importPackage(Packages.org.eclipse.birt.chart.model.attribute);

var xAxis = chart.getAxes().get(0);
var yAxis = xAxis.getAssociatedAxes().get(0);
var xSerieDef = xAxis.getSeriesDefinitions().get(0);
var ySerieDef1 = yAxis.getSeriesDefinitions().get(0);

//logInfo(ySerieDef1.getSeries().get(0).getSeriesIdentifier(), icsc)
ySerieDef1.getSeries().get(0).setSeriesIdentifier("My new series name");

}

or leave it where it is and add:

runSeries = ySerieDef1.getRunTimeSeries();
firstRunSeries = runSeries.get(0);
firstRunSeries.setSeriesIdentifier("My new series name");



Jason
On 10/19/2011 5:52 PM, dpardon wrote:
> Thank you for your reponse Jason.
>
> I set up series label to display "value series name" option, just above each bar. So i'm trying to update this series name to replace it by its parameter value.
>
> I tried your code in the attached report and it works, but labels above each bar chart keep using the old series name :/ Very strange. Are these labels generated before the "beforeGeneration" event?
Re: How to set chart series name in javascript [message #742603 is a reply to message #742510] Thu, 20 October 2011 16:39 Go to previous message
donino donino is currently offline donino doninoFriend
Messages: 183
Registered: July 2011
Senior Member
Thanks a lot!! Fantastic that's exactly what i needed!
Previous Topic:BIRT 2.5.1 cuts off font at auto text when generating a PDF
Next Topic:MEDIAN function on string???
Goto Forum:
  


Current Time: Fri Mar 29 05:18:42 GMT 2024

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

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

Back to the top