apreble Posted September 9 Share Posted September 9 Good morning, Does anyone know of a way that I can add a checkbox to a Text Area to make it an option for users to reverse the Y-Axis scale without having to open the Properties of the visual? Thanks! Link to comment Share on other sites More sharing options...
Solution Niko Maresco Posted September 9 Solution Share Posted September 9 hi apreble, you could do this with an Action Control or a Property Control, but unfortunately there is no checkbox or radio button control in Spotfire. as an alternative, either a Drop-down List Property Control or an Action Control attached to an IronPython script can sort this out for you. i'll outline the steps and provide a script for the latter. i'm assuming you're using a Bar Chart here :) in your Text Area, add a new Action Control: enter a value for Display text and set the Control type to either Button or Link (i recommend Button with a Display text like "Reverse Y-Axis") choose Script from the action types on the left, then click Add >> New script... provide a name for the script, like "reverseYAxis" (no spaces here!) paste the below script into the Script field: # import the class reference for a Bar Chart from Spotfire.Dxp.Application.Visuals import BarChart # cast the `visual` Parameter as a BarChart class bar_chart = visual.As[BarChart]() # toggle the YAxis.Reversed property from False->True or True->False bar_chart.YAxis.Reversed = not bar_chart.YAxis.Reversed click the Add... button to add a new Parameter. name it "visual" and under Debug value choose your visualization from the dropdown, then click OK click Run Script to verify that it's working correctly, and then confirm all open dialogs and there you have it :) here's a screenshot of all the open dialogs in case it's useful to see the whole thing completed 1 1 Link to comment Share on other sites More sharing options...
apreble Posted September 9 Author Share Posted September 9 @Niko Maresco Thank you for the helpful step-by-step! I have 2 questions.... first one- this visual is actually a scatterplot, so I substituted all the "Bar Charts" w/"Scatter plot". Unfortunately this didn't work, but maybe I'm not naming the scatter plot function correctly. Second question- I noticed your version of IronPython was 3.4, and I only have options for 2.0 and 2.7. Is this causing any issues? Link to comment Share on other sites More sharing options...
Niko Maresco Posted September 9 Share Posted September 9 hi apreble, aha, your hypothesis is correct :) in this case, you want "ScatterPlot". here's the complete script: # import the class reference for a Scatter Plot from Spotfire.Dxp.Application.Visuals import ScatterPlot # cast the `visual` Parameter as a ScatterPlot class scatter_plot = visual.As[ScatterPlot]() # toggle the YAxis.Reversed property from False->True or True->False scatter_plot.YAxis.Reversed = not scatter_plot.YAxis.Reversed the version of Python doesn't affect anything in this case. the available selections are dependent on your installed version of Spotfire (i am using 14.4.0). 1 1 Link to comment Share on other sites More sharing options...
apreble Posted September 9 Author Share Posted September 9 Thank you so much Niko, I was able to get it to work! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now