# Changing XYChart Line Stroke Color based on target line. - Perspective

**URL:** <https://forum.inductiveautomation.com/t/changing-xychart-line-stroke-color-based-on-target-line-perspective/74725>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [June 7, 2023, 5:28pm UTC](https://forum.inductiveautomation.com/t/changing-xychart-line-stroke-color-based-on-target-line-perspective/74725 "2023-06-07T17:28:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![S\_B](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@S\_B](https://forum.inductiveautomation.com/u/S_B)\
**Post date:** [June 7, 2023, 5:28pm UTC](https://forum.inductiveautomation.com/t/changing-xychart-line-stroke-color-based-on-target-line-perspective/74725/1 "2023-06-07T17:28:53Z")

</div>

Hello,

I have a XY Chart in perspective. I am trying to create a binding expression that changes the line appearance stroke color to either blue or red based on its position at the target line.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/b/4b21f4229c5943d47e7571b19d51170255961f5b.png)

If the Number of Operations goes above the target line, I would like the line to be colored blue.

If the Number of Operations goes below the target line, I would like the line to be colored red.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/b/cbd94afeec6fa5c27ee94e358fc51e606676c08a.png)

Is this doable in a expression binding on the Line Appearance Stroke Color?

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

Or is a script needed to change the color?

Thanks!

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [June 7, 2023, 6:43pm UTC](https://forum.inductiveautomation.com/t/changing-xychart-line-stroke-color-based-on-target-line-perspective/74725/2 "2023-06-07T18:43:33Z")

</div>

Expressions aren't scripts. Think of them as like Excel functions. They return a value which you can bind to a property. Try this:

```auto
if({tag A} < {tag B},
    '#ff0000',
    '#001aff'
)

```

Or better again, use the [built-in Perspective theme colors](https://docs.inductiveautomation.com/display/DOC81/Perspective+Built-In+Themes#PerspectiveBuiltInThemes-Built-inThemeColors):

```auto
if({tag A} < {tag B},
    '--error',
    '--success'
)

```

or whatever you prefer. These CSS theme colors will adjust to suit when you change themes and are a much easier way of maintaining consisten look and feel across your site.

* * *

Please, please, post formatted code (using the \</\> button) rather than pictures of code, resize the windows and crop the images. 90% of the top one is irrelevant.
