Change color of one point in a XYChart

Hi All,

I want to change the color of some point inside a Chart component. I tried myself but Iโ€™m not so familiar with Java ( yet :wink: ).
After a lot of Googleing around I know I have to determine which renderer class is being used ( org.jfree.chart.renderer.xy.StandardXYItemRenderer ) and create a subclass of it where override the getItemPaint() method to return a specific color for the data item that I wish to highlight, but I donโ€™t know how to do it :sweat_smile:
Any help would be much much appreciated :slight_smile:

Cheers,

Nobody? :disappointed_relieved:

Something like this should do the trick.

	from org.jfree.chart.renderer.xy import StandardXYItemRenderer
	from java.awt import Color
	
	class myXYItemRenderer(StandardXYItemRenderer):
		
		def getItemPaint(self,row,column):
			#whatever criteria you want to use to determine color
			if row == 0 and column >= 12:
				return Color.BLACK
			else:
				return StandardXYItemRenderer.getItemPaint(self,row,column)
				
	chart.getXYPlot().setRenderer(myXYItemRenderer())
2 Likes

Thanks!! :+1::+1:

For posterity:
row is the series
column is the item