# Classic Chart getting Null Paint Exception in X-Trace and Mark modes

**URL:** <https://forum.inductiveautomation.com/t/classic-chart-getting-null-paint-exception-in-x-trace-and-mark-modes/58513>\
**Category:** Ignition\
**Tags:** ignition80, scripting, vision\
**Created:** [April 15, 2022, 10:27pm UTC](https://forum.inductiveautomation.com/t/classic-chart-getting-null-paint-exception-in-x-trace-and-mark-modes/58513 "2022-04-15T22:27:40Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zachary\_Zipper](https://avatars.discourse-cdn.com/v4/letter/z/bbe5ce/32.png) [@Zachary\_Zipper](https://forum.inductiveautomation.com/u/Zachary_Zipper)\
**Post date:** [April 15, 2022, 10:27pm UTC](https://forum.inductiveautomation.com/t/classic-chart-getting-null-paint-exception-in-x-trace-and-mark-modes/58513/1 "2022-04-15T22:27:40Z")

</div>

I am currently using the Classic Chart’s configureChart() function to change the color of the data points if it is outside of a user-defined spec limit. It is currently working as expected.

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

However, when I go into X-Trace or Mark mode, I get this error

```auto
java.lang.IllegalArgumentException: Null 'paint' argument.
	at org.jfree.chart.annotations.XYTextAnnotation.setPaint(XYTextAnnotation.java:222)
	at com.inductiveautomation.factorypmi.application.components.chart.runtime.AutoAnnotateXYPlot.draw(AutoAnnotateXYPlot.java:634)
	at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1227)
...

```

This is the code I am using in my configureChart()

```auto
	from org.jfree.chart.renderer.xy import XYLineAndShapeRenderer
	from java.awt import Color
	
	specData = self.SpecData
	
	if specData.getRowCount() == 0:
		rend = XYLineAndShapeRenderer()
	else:
		highVal = specData.getValueAt(0, 1)
		lowVal = specData.getValueAt(0, 2)
		class myRenderer(XYLineAndShapeRenderer):
			def getItemPaint(self, row, column):
				val = self.getPlot().getDataset(0).getYValue(row, column)
				if val > highVal or val < lowVal:
					return Color.red
				else:
					return Color.blue
		rend = myRenderer()	
		
	chart.getXYPlot().setRenderer(rend)

```

Is there something I am missing in my overridden getItemPaint() method to cause it to send a null value?

---

<div class="post-metadata">

**Author:** ![Zachary\_Zipper](https://avatars.discourse-cdn.com/v4/letter/z/bbe5ce/32.png) [@Zachary\_Zipper](https://forum.inductiveautomation.com/u/Zachary_Zipper)\
**Post date:** [April 18, 2022, 4:44pm UTC](https://forum.inductiveautomation.com/t/classic-chart-getting-null-paint-exception-in-x-trace-and-mark-modes/58513/2 "2022-04-18T16:44:06Z")

</div>

Update: I have tried testing getItemPaint() by having it _always_ return **Color.blue**. This still causes the null paint exception. When I don’t override the getItemPaint() method at all, this exception does not happen. Am I not allowed to override this method? What could possibly be happening on Ignition’s backend to change that value to null?

---

<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:** [April 18, 2022, 5:13pm UTC](https://forum.inductiveautomation.com/t/classic-chart-getting-null-paint-exception-in-x-trace-and-mark-modes/58513/3 "2022-04-18T17:13:59Z")

</div>

What exact version are you using? Your line numbers don’t match up with mine in the current codebase, so I can’t see exactly which path we’re following to end up sending a null.

What’s happening, broadly, is that we’re trying to send a color to the annotation, and the annotation itself (vanilla JFreeChart code) is guarding against a null paint.

---

<div class="post-metadata">

**Author:** ![Zachary\_Zipper](https://avatars.discourse-cdn.com/v4/letter/z/bbe5ce/32.png) [@Zachary\_Zipper](https://forum.inductiveautomation.com/u/Zachary_Zipper)\
**Post date:** [April 18, 2022, 5:16pm UTC](https://forum.inductiveautomation.com/t/classic-chart-getting-null-paint-exception-in-x-trace-and-mark-modes/58513/4 "2022-04-18T17:16:56Z")

</div>

I am using **8.0.12**.

---

<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:** [April 18, 2022, 5:24pm UTC](https://forum.inductiveautomation.com/t/classic-chart-getting-null-paint-exception-in-x-trace-and-mark-modes/58513/5 "2022-04-18T17:24:36Z")

</div>

This is our code that’s ultimately returning null and assigning it to the annotation object:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/d/5d7669e009f72be799c129d5e76cd37378806aeb.png)

It looks like the call `getSeriesPaint` on your subclassed renderer is where the null is coming from. Try overriding `getSeriesPaint` in your subclass as well.

---

<div class="post-metadata">

**Author:** ![Zachary\_Zipper](https://avatars.discourse-cdn.com/v4/letter/z/bbe5ce/32.png) [@Zachary\_Zipper](https://forum.inductiveautomation.com/u/Zachary_Zipper)\
**Post date:** [April 18, 2022, 5:33pm UTC](https://forum.inductiveautomation.com/t/classic-chart-getting-null-paint-exception-in-x-trace-and-mark-modes/58513/6 "2022-04-18T17:33:10Z")

</div>

This works, thank you so much!

---

<div class="post-metadata">

**Author:** ![rpavlicek](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rpavlicek/32/55868_2.png) [@rpavlicek](https://forum.inductiveautomation.com/u/rpavlicek)\
**Post date:** [June 27, 2022, 9:52pm UTC](https://forum.inductiveautomation.com/t/classic-chart-getting-null-paint-exception-in-x-trace-and-mark-modes/58513/7 "2022-06-27T21:52:03Z")

</div>

> [@paul-griffith](#):
>
> getSeriesPaint

Can someone expand on this and show where in the @Zachary_Zipper's you would need to override getSeriesPaint? I'm assuming you make another definition like below:

`def getSeriesPaint(self, row, column)`

When I did that, it says it needs three arguments and only 2 given, example below:

```auto
def getSeriesPaint(self, row, column):
	valx = plot.getDataset().getXValue(row, column)
	valy = plot.getDataset().getYValue(row, column)
	if valx > 6:
		return Color.RED
	else:
		return Color.GREEN

```

---

<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:** [June 27, 2022, 10:10pm UTC](https://forum.inductiveautomation.com/t/classic-chart-getting-null-paint-exception-in-x-trace-and-mark-modes/58513/8 "2022-06-27T22:10:46Z")

</div>

`getSeriesPaint` would accept `self` and one additional argument `series` (an integer). Not as convenient as a row/column.

---

<div class="post-metadata">

**Author:** ![rpavlicek](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rpavlicek/32/55868_2.png) [@rpavlicek](https://forum.inductiveautomation.com/u/rpavlicek)\
**Post date:** [June 27, 2022, 10:25pm UTC](https://forum.inductiveautomation.com/t/classic-chart-getting-null-paint-exception-in-x-trace-and-mark-modes/58513/9 "2022-06-27T22:25:54Z")

</div>

I’m having trouble on constructing the code for this. For simplicity, I’m working with just a single series, so zero (0) is what I’m assuming I can use.

---

<div class="post-metadata">

**Author:** ![rpavlicek](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rpavlicek/32/55868_2.png) [@rpavlicek](https://forum.inductiveautomation.com/u/rpavlicek)\
**Post date:** [June 27, 2022, 10:37pm UTC](https://forum.inductiveautomation.com/t/classic-chart-getting-null-paint-exception-in-x-trace-and-mark-modes/58513/10 "2022-06-27T22:37:27Z")

</div>

Ok, so it seems it was as simple as writing this:

```auto
def getSeriesPaint(self, series):
	return Color.BLACK

```

It didn’t matter what I put in the 2nd argument as long as it had a string. It doesn’t accept an integer itself. What this did was return the color to the trace or mark label font.
