Jump to content

Script to change "Color By" columns through buttons


Julyana Saraiva

Recommended Posts

I have this chart, which is by default colored by the column "UT":

 

I need to create two buttons, to alternate between "Color by UT" (as previously showed) and "Color by Regional", as this:

 

I know I have to create the buttons inside a text area, but I don't know how to create the scripts for theses buttons, can you help me

 

 

So far, I have found this example:

from Spotfire.Dxp.Application.Visuals import *

from Spotfire.Dxp.Data import *

for vis in Application.Document.ActivePageReference.Visuals:

if vis.Title == "Viso por UT ou Regional ACT MTD MR$":

visualContentObject = vis.As[Visualization]()

visualContentObject.Data.WhereClauseExpression = xxxxxxxxxxxxxxxxx

Link to comment
Share on other sites

Hello,

You are on the right track, I think. Here is a way that should work...you will need to access the ColorAxis expression property. Just replace COL_NAME with your column name

 

from Spotfire.Dxp.Application.Visuals import *

from Spotfire.Dxp.Data import *

 

for vis in Application.Document.ActivePageReference.Visuals:

if vis.Title == "Viso por UT ou Regional ACT MTD MR$":

visualContentObject = vis.As[Visualization]()

 

visualContentObject.ColorAxis.Expression = "" #edit COL_NAME

Link to comment
Share on other sites

It didin't work. It gave this message:

Could not perform action 'Regionais'.

Could not execute script 'Viso por Regional': 'NoneType' object has no attribute 'ColorAxis'

at Spotfire.Dxp.Application.Scripting.ScriptService.Execute(ScriptDefinition script, Dictionary`2 scope, InternalLibraryManager internalLibraryManager, NotificationService notificationService)

at Spotfire.Dxp.Application.Scripting.ScriptManager.c__DisplayClass8_0.b__0()

at Spotfire.Dxp.Framework.Commands.CommandHistory.Transaction(Executor executor, Boolean visible, Boolean sticky, Guid stickyGuid, Boolean isHighlight)

at Spotfire.Dxp.Framework.Commands.CommandHistory.Transaction(String displayName, Executor executor)

at Spotfire.Dxp.Application.Scripting.ManagedScript.Execute(Dictionary`2 environment)

at Spotfire.Dxp.Application.HtmlTextAreaControls.ActionControl.ModifyCore(Object value)

at Spotfire.Dxp.Application.Visuals.HtmlTextArea.InteractWithControl(String id, Action`1 interaction)

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