Jump to content

Add column into color scheme grouping using Spotfire Ironpython


Kem Azlan
Go to solution Solved by Magnus Rylander,

Recommended Posts

Hi Heleen. Thanks for the reply. I tried to refer on this topic:

However, the code above is for creating new color scheme grouping and then add some column into it. But I try to figure out if we need to add new column from the data into color scheme grouping that has been created into Table visualization, but I cannot find the suitable code to configure this. I hope this helps.

Edited by Kem Azlan
Link to comment
Share on other sites

Hi @Heleen Snelting. Alternatively, maybe I can reuse the code sample in this topic:

But, all the color that I have applied into color scheme grouping, will be reset to default color. Is there any IronPython code to create color scheme grouping along with below color gradient settings (Noted that the visualization is in Table):

image.png.e3ddcadb89509b0dc219beb03d6d153b.png

 

I also hope this helps.

 

Edited by Kem Azlan
Image change
Link to comment
Share on other sites

  • Solution

Hi @Kem Azlan,

Here's a script that might help you:
 

# This script sets up continuous coloring of a table plot.
# It assumes there are two numerical columns, Y and Y in the table.
from Spotfire.Dxp.Application.Visuals import CategoryKey, TablePlot
from Spotfire.Dxp.Application.Visuals.ConditionalColoring import ConditionValue
from System.Drawing import Color

viz = table.As[TablePlot]()

# Add a new coloring
coloring = viz.Colorings.AddNew("MyColoring");

# Map the columns we want to color to it.
viz.Colorings.AddMapping(CategoryKey("X"), coloring)
viz.Colorings.AddMapping(CategoryKey("Y"), coloring)

# Make the coloring compute its values across all the columns
coloring.EvaluatePerColumn = False

# Create a color gradient 
colorRule =  coloring.AddContinuousColorRule()
colorRule.Breakpoints.Add(ConditionValue.CreateLiteral(0), Color.White)
colorRule.Breakpoints.Add(ConditionValue.CreateLiteral(1), Color.LightPink)
colorRule.Breakpoints.Add(ConditionValue.MaxValue, Color.Red)

# Note that you can use epxressions for the breakpoints if you like
# In that case you would reference the cell values with [Axis.Color] like below:
# colorRule.Breakpoints.Add(ConditionValue.CreateExpression("Max([Axis.Color])"), Color.Red)

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...