Skip to main content



      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 03:51 Go to next message
Eclipse UserFriend
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 04:15] by Moderator

Re: How to set chart series name in javascript [message #741466 is a reply to message #741128] Wed, 19 October 2011 11:03 Go to previous messageGo to next message
Eclipse UserFriend
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 17:52 Go to previous messageGo to next message
Eclipse UserFriend
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 10:58 Go to previous messageGo to next message
Eclipse UserFriend
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 12:39 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 08:38:57 EDT 2025

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

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

Back to the top