Change Legend Name dynamically in XY chart?

I am using XY chart . i want to change the legend name dynamically…
can any one help me out please

from org.jfree.chart.labels import StandardXYItemLabelGenerator

plot0 = chart.getXYPlot()
	xyBarRenderer = plot0.XYBarRenderer();
	xyBarRenderer.setDrawBarOutline( false );
	xyBarRenderer.setBaseToolTipGenerator( StandardXYToolTipGenerator())

I have tired something like that. but its not working

What exactly are you trying to change?
the legend should already be dynmic dependnign on the names you gave

I have 4 dataset in xy chart… I have configured script for changing tha x axis label dynamically as per user wish… Soo i am planing put that same name in legend alsoo… Actually legend taking the names from dataset column… But i planing to change the legend name based on my label name

it is perspective right?

Noo vision

ah which chart are you usuing? the xy chart is perspective xd

Classic chart

ah idk to much about that, try setFixedLegendItems() maybe

Thanks i wll check