Jump to content

Script to Change Linechart Format based on Document Property


Stuart Wise

Recommended Posts

Hi all,

This seems so obvious and yet I cant get it to work.

I have built some simple code to look up a document property and depending on what chart it is change the formatting.

I have 6 charts and despite them being named 1,2,3,4,5 and 6. They are set up as a string hence the "" either side.

 

Charts 2 and 5 need to be formatted as % and the rest as Number.

The code runs fine with no errors and have even placed print "check" on each line to make sure it was following the correct path.

But despite the fact it seems to run fine and I get no errors, the formatting is not changed on the chart.

Is it because it's a Monday and I am missing something, or is it just acting up

Code below:

from Spotfire.Dxp.Data import *

from Spotfire.Dxp.Application.Visuals import *

from Spotfire.Dxp.Data.Formatters import *

myVis = myVis.As[Visualization]()

formatter = DataType.Real.CreateLocalizedFormatter()

if Document.Properties['ChartType'] == "2":

formatter.Category = NumberFormatCategory.Percentage

formatter.DecimalDigits = 2

formatter.GroupSeparatorEnabled = True

elif Document.Properties['ChartType'] == "5":

formatter.Category = NumberFormatCategory.Percentage

formatter.DecimalDigits = 2

formatter.GroupSeparatorEnabled = True

else:

formatter.Category = NumberFormatCategory.Number

formatter.DecimalDigits = 0

formatter.GroupSeparatorEnabled = True

myVis.YAxis.Scale.Formatting.RealFormatter = formatter

 

Many thanks for your help.

Stuart

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