Change colour of item in Chart

from java.awt import Color
from org.jfree.chart.renderer.xy import XYLineAndShapeRenderer
from java.awt.geom import Rectangle2D
chart = event.source.parent.getComponent('Chart').getChart()

ucl = 58.0
plot = chart.getPlot()

class MyRenderer(XYLineAndShapeRenderer):	
	def getItemPaint(self,series,row):
		if series == 0 and plot.getDataset(0).getYValue(series, row) > ucl: 
			return Color.RED
		else: 
			return Color.BLUE

renderer = MyRenderer()
renderer.setSeriesLinesVisible(0,False)
renderer.setSeriesShape(0, Rectangle2D.Double(-3, -3, 6, 6)) 
plot.setRenderer(renderer)
3 Likes