# Problem getBarColor

**URL:** <https://forum.inductiveautomation.com/t/problem-getbarcolor/20153>\
**Category:** Ignition\
**Created:** [October 15, 2018, 2:56pm UTC](https://forum.inductiveautomation.com/t/problem-getbarcolor/20153 "2018-10-15T14:56:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrea.montresor](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@andrea.montresor](https://forum.inductiveautomation.com/u/andrea.montresor)\
**Post date:** [October 15, 2018, 2:56pm UTC](https://forum.inductiveautomation.com/t/problem-getbarcolor/20153/1 "2018-10-15T14:56:26Z")

</div>

CIao,

I have a problem with the Bar Chart component. We are using the extended function **getBarColor**  
We would like to have a dynamic target based on a Tag. So the Tag should be dynamic and we have a property defined in the window that is called ID\_MACHINE.  
When we try to get the string value we have the error “Illegal character {”. The same string value ‘{Root Container.ID\_MACHINE}’ is used in the query.

This is our code:

from java.awt import Color  
machine = ‘{Root Container.ID\_MACHINE}’

val = system.tag.read(‘VisionTag/’+machine+’/TARGET\_VALUE’).getValue()  
if value \> val:  
return Color.GREEN  
else:  
return Color.RED

Could you please help us? How can we do to set dynamic Tag name?

Thanks  
Andrea

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 15, 2018, 3:17pm UTC](https://forum.inductiveautomation.com/t/problem-getbarcolor/20153/2 "2018-10-15T15:17:11Z")

</div>

The string substitution of properties and tags using curly braces doesn’t work in scripts. You must use jython property access syntax or system.tag.read\*() functions, respectively. Something like `self.parent.ID_MACHINE`. Consider adding another custom property that uses an indirect tag binding to retrieve the target value outside of the getBarColor() method. That will eliminate the repeated tag reads for each bar to display. Reading a property is dramatically faster.

---

<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:** [October 15, 2018, 3:17pm UTC](https://forum.inductiveautomation.com/t/problem-getbarcolor/20153/3 "2018-10-15T15:17:38Z")

</div>

> [@andrea.montresor](#):
>
> `machine = '{Root Container.ID_MACHINE}'`

You can't use the curly brace (`{}`) reference syntax in scripting. So, to achieve the same result within the `getBarColor` extension function, you'll need to start from the `self` variable that's provided - which is a reference to the bar chart component itself. From there, go _up_ the component hierarchy to the root container, and read your custom parameter:  
`machine = self.parent.ID_MACHINE`
