Jump to content

Locking color scheme between two visualizations


Rudy Ratner

Recommended Posts

I followed the instructions of this postto create a cross table and convert it to a scrolling legend that links to a plot.

Both the plot and the cross table are sourced from the same data table that gets refreshed with new data from a data node every time the user executes the query. The schema remains the same.

I used the "Spotfire Categorical" color scheme for both the plot and the crossTable so that their colors would match. However every time the query is executed and the data table is refreshed, the color scheme gets reset and I have to redefine the color scheme for the two visualisations again.

Here is a screenshot of the issue:

 

Is there a way to lock the color scheme between the two visualisations so that it stays the same even if the data table is refreshed

Any insight would be greatly appreciated!

Thank You

Link to comment
Share on other sites

There is a way to fix the colour scheme for any column of your choice. If you go to Data>Column Properties>Properties tab you see there areDefaultContinuousColourScheme and DefaultCategoricalColorScheme properties. You can edit them, and set them to the name of the colour scheme of your choice. (Unfortunately there is no drop down list, you have to type the colour scheme name manually). This would keep the chosen colour scheme for thatcolumn.

Since I don't know your data and setup I don't know how many and which columns are involved here, but hope this helps.

Link to comment
Share on other sites

Hi Gaia,Thank you for that!. I tried doing that but the color scheme still changes when the data table gets refreshed. I am setting up the color scheme for only one column. 

It seems to fail only when the data table is refreshed. If I just switch filters within the same data table it seems to work fine. I have updated my post to include a screenshot of the issue. 

Link to comment
Share on other sites

You can apply the color scheme from on visualization to another visualization in the properties of the visualization using COLOR SCHEME -> FROM VISUALIZATION -> your viz -> COLORS MATCHED TO VALUES. However unfortunately this does not lock the schemes.

 

But I think if this can be done by the user in the properties by clicking then it should be possible to do it as well with an IronPython script. Then you would have to run the script whenever you reload data. A script for applying a certain color scheme to one column (Gaia's approach) should work as well. 

 

Maybe this discussion is helpful:

 

https://community.spotfire.com/questions/script-apply-bar-chart-color-schemes-combination-chart-colors-matched-values

Link to comment
Share on other sites

@fabd, 

 

I think a script is the right way to go for my data table that keeps getting refreshed. 

 

Thank you for the link to the discussion. I guess I have to find the correct "Apply"  Namespace in the ironpython script that will be able to apply the coloring scheme from my scatterplot visualization. 

 

I tried a stab at running the following script but I get an error saying that it

 

cannot import name Cross Table

 

from Spotfire.Dxp.Application.Visuals import CrossTable
visuals = Document.ActivePageReference.Visuals
for vis in visuals:
if (vis.Title == "Legend"):
	bc = vis.As[CrossTable]()
	axis = bc.ColorAxis
	color = axis.Coloring
	color.Apply("my_color_scheme")

 

Would you happen to know of any good sources to investigate for such spotfire related iron python scripts

 

Thank You

 

 

Link to comment
Share on other sites

Please try CrossTablePlot instead.

 

There is no Class CrossTable in the Spotfire.Dxp.Application.Visuals namespace

 

https://docs.tibco.com/pub/doc_remote/spotfire/7.9.0/TIB_sfire-analyst_7.9.0_api/html/N_Spotfire_Dxp_Application_Visuals.htm

 

My knowledge in scripting is very low. So I probably can't help further if questions get more specific. But this forum has also some IronPython experts.

Link to comment
Share on other sites

Hmm this is interesting. What is probably happening is the data refresh brings in new categorical values, and that throws the color schemes out of sync. Probably something deep inside Spotfire on how default color schemes are determined that I don't know!

 

But I have an idea you can try....

You can set the color schemes of individual visualizations from IronPython. You only need to have:

1) A color scheme of choice saved to your DXP

2) A way to reference your relevant visualizations

3) A way to trigger the IronPython script

 

For Step 1:

In any visualization, go to Visualization Properties and save the existing color scheme with a name like "ColorSchemeName". You do this through the icon that looks like two sheets of paper.

 

For Step 2:

You can reference a visualization and assign a color scheme like this

 

For Step 3:

Try triggering your IronPython script in a way similar tothis method, but rather than triggering it when the dashboard loads, instead put the data function in your library, and add it as a transform to your data canvas in data loading (or you can do it when dashboard loads if it makes more sense for you)

 

Alternatively, were you able to have success with the method Gaia suggested Here is an article on how to skip steps 2 and 3 and instead just use Column Properties.

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...