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

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.

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.

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

Or is a script needed to change the color?

Thanks!

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

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

Or better again, use the built-in Perspective theme colors:

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.

1 Like