# Vision Chart Component Change Series Line Color Based On Value for Each

**URL:** <https://forum.inductiveautomation.com/t/vision-chart-component-change-series-line-color-based-on-value-for-each/56425>\
**Category:** Ignition\
**Tags:** vision, ignition81, scripting\
**Created:** [February 22, 2022, 9:53pm UTC](https://forum.inductiveautomation.com/t/vision-chart-component-change-series-line-color-based-on-value-for-each/56425 "2022-02-22T21:53:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![curtisfennell](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/curtisfennell/32/39017_2.png) [@curtisfennell](https://forum.inductiveautomation.com/u/curtisfennell)\
**Post date:** [February 22, 2022, 9:53pm UTC](https://forum.inductiveautomation.com/t/vision-chart-component-change-series-line-color-based-on-value-for-each/56425/1 "2022-02-22T21:53:40Z")

</div>

Good day,

I am working with the Chart Component in Vision. I am trying to represent open or closed based on value. I have used the door number. If Door5 is 5 then it is closed, if it is 5.5 this is open.

I would like to color each line/series based on if the value, example:

If Door5 most recent value (row0) \> 5:  
Return Red  
Else  
Blue

Ideally the chart would all be red and blue. Red if the corresponding door is open vs blue if closed. In the example Door1 is blue and closed, but Door3 would be red.

I tired piggybacking [Change colour of item in Chart - #9 by lrose](https://forum.inductiveautomation.com/t/change-colour-of-item-in-chart/35729/9) and their solution.

Using this, I’m able to get the first series, but not sure where to go from there.

```
from java.awt import Color
from org.jfree.chart.renderer.xy import XYLineAndShapeRenderer
from java.awt.geom import Rectangle2D

#grabs a reference to plot of the chart
plot = chart.getPlot()

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

#create an instance of your renderer			
renderer = MyRenderer()

#These lines modify the rendering of the data series
renderer.setSeriesLinesVisible(0,False)

#set the renderer of the plot to your custom renderer
plot.setRenderer(renderer)

```

Example of Chart with Script.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/a/9ad9f9796137068990affec6cc3676e5a52c11be.png)

Example of Dataset:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/2/527743c570d22617476245c4fbd17cffc4d95cb1.png)

Example of Chart w/o script:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/d/fd9404535cbf625fd64a93749e6d585f94b3b07c.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [February 22, 2022, 10:53pm UTC](https://forum.inductiveautomation.com/t/vision-chart-component-change-series-line-color-based-on-value-for-each/56425/3 "2022-02-22T22:53:30Z")

</div>

```auto
class MyRenderer(XYLineAndShapeRenderer):	
	def getItemPaint(self,series,row):
		if plot.getDataset(0).getYValue(series, row) > (series + 1):
			return Color.RED
		else:
			return Color.BLUE

```

Surely?

---

<div class="post-metadata">

**Author:** ![curtisfennell](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/curtisfennell/32/39017_2.png) [@curtisfennell](https://forum.inductiveautomation.com/u/curtisfennell)\
**Post date:** [February 22, 2022, 10:57pm UTC](https://forum.inductiveautomation.com/t/vision-chart-component-change-series-line-color-based-on-value-for-each/56425/4 "2022-02-22T22:57:17Z")

</div>

Yes… Its been a long day. Thank you!
