# How to change Bar chart color based on value

**URL:** <https://forum.inductiveautomation.com/t/how-to-change-bar-chart-color-based-on-value/14013>\
**Category:** Ignition\
**Created:** [April 11, 2017, 1:46pm UTC](https://forum.inductiveautomation.com/t/how-to-change-bar-chart-color-based-on-value/14013 "2017-04-11T13:46:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Slurpee](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@Slurpee](https://forum.inductiveautomation.com/u/Slurpee)\
**Post date:** [April 11, 2017, 1:46pm UTC](https://forum.inductiveautomation.com/t/how-to-change-bar-chart-color-based-on-value/14013/1 "2017-04-11T13:46:08Z")

</div>

Ignition newbie here.

I am working on a production output monitoring display here using bar chart and I want that  
my bar color will change based on it’s value like if it did not reach the target.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/1/10341983ac0f8342b00e51e06f14f79bee2fdc91.png)

I’ve tried this script in which I found in another topic here but it doesn’t seem to be working for me.  
I attached this script in the Extension Functions \ configureChart

from org.jfree.chart.renderer.category import BarRenderer  
from java.awt import Color  
class myBarRenderer(BarRenderer):  
def getItemPaint(self, row, column):  
v = chart.getCategoryPlot().getDataset().getValue(row, column)  
if v \> 30:  
return Color.green  
else:  
return Color.red  
plot = chart.getCategoryPlot()  
plot.setRenderer(myBarRenderer())

can somebody here guide me if there is an easier way to do this.

---

<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 11, 2017, 9:05pm UTC](https://forum.inductiveautomation.com/t/how-to-change-bar-chart-color-based-on-value/14013/2 "2017-04-11T21:05:09Z")

</div>

The script you posted should work; the only suspicion I have is about the chart itself. Are you using the classic chart, and if so, are you using a bar type renderer on it? Also, are you receiving any actual error, or is the code just apparently not working? Try looking in the output console (Ctrl + Shift + C in the Designer) to see if any error messages or warnings are being logged.

---

<div class="post-metadata">

**Author:** ![anna](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@anna](https://forum.inductiveautomation.com/u/anna)\
**Post date:** [April 11, 2017, 9:13pm UTC](https://forum.inductiveautomation.com/t/how-to-change-bar-chart-color-based-on-value/14013/3 "2017-04-11T21:13:05Z")

</div>

Slurpee,

If you are using the Bar Chart component, you do not need that script - just use the getBarColor extension function:

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/3/3be68e57e8a99ed43e923d82a465c510a7248c57.PNG)

---

<div class="post-metadata">

**Author:** ![Slurpee](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@Slurpee](https://forum.inductiveautomation.com/u/Slurpee)\
**Post date:** [April 12, 2017, 1:04pm UTC](https://forum.inductiveautomation.com/t/how-to-change-bar-chart-color-based-on-value/14013/4 "2017-04-12T13:04:16Z")

</div>

@paul-griffith@anna  
Thank you so much for your reply, I am actually using the easy chart but I was able to make it work in a different way.  
I have used 2 different series by adding conditions in my query.  
I will try to use this method on my next project or if I need to make some changes again on this project.

---

<div class="post-metadata">

**Author:** ![felipe2010silva](https://avatars.discourse-cdn.com/v4/letter/f/54ee81/32.png) [@felipe2010silva](https://forum.inductiveautomation.com/u/felipe2010silva)\
**Post date:** [January 12, 2021, 6:28pm UTC](https://forum.inductiveautomation.com/t/how-to-change-bar-chart-color-based-on-value/14013/5 "2021-01-12T18:28:40Z")

</div>

Thank you very much. solution very simple, but very efficient.
