Stuart Wise Posted April 6, 2020 Share Posted April 6, 2020 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 More sharing options...
Shandilya Peddi Posted April 6, 2020 Share Posted April 6, 2020 I'm guessing it could be with data type issue. Can you check if the column's data type is Real or Integer, based on that I think the below should change myVis.YAxis.Scale.Formatting.RealFormatter = formatter or myVis.YAxis.Scale.Formatting.IntegerFormatter = formatter Link to comment Share on other sites More sharing options...
Stuart Wise Posted April 7, 2020 Author Share Posted April 7, 2020 It wasn't IntegerFormatter but you were indeed correct, the column was set as Currency. Once I realised that I changed it to CurrencyFormatter and it worked a charm. Many thanks for your help 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