Jump to content

Flip x-axis orientation in barchart using Iron Python script


Michael Zaragoza

Recommended Posts

I'm totally new to Iron Python scripting.

I want to write a script where the x-axis in a bar chart can be flipped from horizontal to vertical depending on it's current orientation.

I tried the following code but it appears that the comparison operation I'm attempting isn't valid. Is it just a matter of bad syntax or something deeper

from Spotfire.Dxp.Application.Visuals import *

myVis = myVis.As[barChart]()

if (myVis.XAxis.Scale.LabelOrientation == 0) :

myVis.XAxis.Scale.LabelOrientation = 1

else: myVis.XAxis.Scale.LabelOrientation = 0

Thanks!

Link to comment
Share on other sites

Hi

this worked for me (check indenting that may have been lost in copying and pasting). LabelOrientation is itself a class and you need to compare its members this way:

from Spotfire.Dxp.Application.Visuals import *

myVis = myVis.As[barChart]()

if (myVis.XAxis.Scale.LabelOrientation == LabelOrientation.Horizontal) :

myVis.XAxis.Scale.LabelOrientation = LabelOrientation.Vertical

else: myVis.XAxis.Scale.LabelOrientation = LabelOrientation.Horizontal

This flips just the label of the x axis, presumably what you wanted

Gaia

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