Jump to content

Switch color by property using Iron python


Prashant S A
Go to solution Solved by David Boot-Olazabal,

Recommended Posts

Posted (edited)

Hi David,

Thanks for helping out.

What I am looking for is, how to switch between 'cell values' and 'Region' here in cross table using Iron python script.(attached image below)
image.thumb.png.827c91417e97b184e232cd09260ce238.png

Edited by Prashant S A
Link to comment
Share on other sites

  • Solution

Hi Prashant, 

My colleague has created a working script for this.

Since you're on 12.0.3 and we work in Spotfire 14, I'll add the script and explain what we have done.

The solution comprises of 3 steps:
- Add a new text area;
- set up a document property called colorBy (see screenshot below). This is a drop down list property with Fixed values (you should replace the Region row with your own variable name and add others if needed);
- create a new script in which you add a parameter for the crosstab (in the script, this is the cross_table). This script should be added to the text area in the form of a button (in the screenshot below, this is the 'change' button.

image.thumb.png.681eb86d07978ad4d6a0d20e5407d5f7.png

 

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

cross_table = cross_table.As[CrossTablePlot]()
colour_property = Document.Properties['colorBy']
categoryKey=CategoryKey(colour_property)
cross_table.ColorCategory = categoryKey

Now, when you select one of the values from the drop down list and hit the change button, you will see that the coloring changes slightly, since the Color by has changed from (Cell values) to Region (in our example).

If needed, you can let the script run automatically upon changing the document property colorBy, by adding the script to the property via the Script button (see screenshot).

Hope this helps you.

Kind regards,

David

  • Like 1
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...