IronPython script for conditional coloring

Hi,

I'm actually trying to make a script in order to change color expression and rules depending on a property control. My script works for categorical rule but doesn't for continious rules. Here is my script and the Error message, do you see something wrong or you have some advises :

Traceback (most recent call last):
  File "Spotfire.Dxp.Application.ScriptSupport", line unknown, in ExecuteForDebugging
  File "<string>", line 21, in <module>
NameError: name 'ConditionValue' is not defined

from Spotfire.Dxp.Application.Visuals import *
from System.Drawing import Color

tree = treemap.As[Treemap]()
tree.ColorAxis.Coloring.Clear()
p = Document.Properties["DisplayHeatMapOption"]
if p==0:
    tree.ColorAxis.Expression = "Expression_1"
    ColorRule = tree.ColorAxis.Coloring.AddCategoricalColorRule()
    ColorRule.Item[0] = Color.FromName("Green")
    ColorRule.Item[-1] = Color.FromName("Orange")
    ColorRule.Item[1] = Color.FromName("Red")
    
elif p==1:
    tree.ColorAxis.Expression = "Expression_2"
    ColorRule = tree.ColorAxis.Coloring.AddContinuousColorRule()
    ColorRule.IntervalMode = ColorRule.IntervalMode.Gradient
    ColorRule.Breakpoints.Add(ConditionValue.CreateExpression(0), Color.FromName("Green"))
    ColorRule.Breakpoints.Add(ConditionValue.CreateExpression(${PropertyControl}), Color.FromName("Red"))
    ColorRule.Breakpoints.Add(ConditionValue.CreateExpression(100), Color.FromName("Red"))
elif p==2:
    tree.ColorAxis.Expression="Expression_3"
    ColorRule = tree.ColorAxis.Coloring.AddContinuousColorRule()
    ColorRule.IntervalMode = ColorRule.IntervalMode.Segments
    ColorRule.Breakpoints.Add(ConditionValue.CreateExpression(0), Color.FromName("Red"))
    ColorRule.Breakpoints.Add(ConditionValue.CreateExpression(1), Color.FromName("Orange"))
    ColorRule.Breakpoints.Add(ConditionValue.CreateExpression(1.33), Color.FromName("Green"))
elif p==3:
    tree.ColorAxis.Expression="Expression_4"

ColorRule.IntervalMode = ColorRule.IntervalMode.Segments
    ColorRule.Breakpoints.Add(ConditionValue.CreateExpression(0), Color.FromName("Red"))
    ColorRule.Breakpoints.Add(ConditionValue.CreateExpression(1), Color.FromName("Orange"))
    ColorRule.Breakpoints.Add(ConditionValue.CreateExpression(1.33), Color.FromName("Green"))

else: 
    tree.ColorAxis.Coloring.Clear()

Thanks a lot,

Thomas.

(1) Answer

Login