Report - Change timeseries chart legend with script

Hi,

I create a report chart with pens below :

I have list of dictionnaries like [{'key':'value1','title':'my pen title'} , ...]
How can I dynamically put my pens' titles in the chart legend by script ?

Thanks

You'll need to adjust your pen names via the configureChart hook. I'd recommend searching the forum for example code to start from.

My chart is in a table row which depends on values in a dataset like below :
image
How can I get my legend variable in chart script ?

	from org.jfree.chart import JFreeChart
	from org.jfree.chart.plot import XYPlot
	from org.jfree.data.xy import XYSeriesCollection, XYSeries
	plot = chart.getXYPlot()
	dataset = plot.getDataset()
	# Create a new dataset with updated series keys
	newKeysDict =  [{'value1':'my pen title'} , ...]
	if dataset is not None and dataset.getSeriesCount() > 0:
	    newDataset = XYSeriesCollection()
	    for i in range(dataset.getSeriesCount()):
            seriesKey = dataset.getSeriesKey(i)            
			newLabel = newKeysDict[seriesKey]  # Update the label
			# Create a new series (you'll need to copy data points)
			newSeries = XYSeries(newLabel)
			for j in range(dataset.getItemCount(i)):
			    x = dataset.getXValue(i, j)
			    y = dataset.getYValue(i, j)
			    newSeries.add(x, y)  # Add data points
			newDataset.addSeries(newSeries)
	
	    # Set the new dataset to the plot
	    plot.setDataset(newDataset)

in case anyone is looking for something similar.