David Law 2 Posted December 16, 2020 Share Posted December 16, 2020 Hi, I would like to write a python script to create a drop down list for user to change the font size of the bar chart label. Does anyone have an example on how to do it that I can use as a reference Many thanks in advance! DLWEB Link to comment Share on other sites More sharing options...
Gaia Paolini Posted December 17, 2020 Share Posted December 17, 2020 Please check this question: https://community.spotfire.com/questions/ironpython-script-allow-user-toggl... and this site: https://www.sf-ref.com/ironpython/visualizations/bar-chart/labels/ You can add an integer document property (say labelSize) that is set in the drop down, then attach a script to this document property, such as the one below, where barchart is an input parameter of type Visualization (your target barchart): Font is part of the Microsoft System.Drawing namespace: https://docs.microsoft.com/en-us/dotnet/api/system.drawing.fontview=dot... If the default font is not on your machine you can download and install it on Windows, or you might want to specify another font name directly. Looks like Iron Python can only access the installed fonts. ################################# from Spotfire.Dxp.Application.Visuals import * from System.Drawing import Font newsize=Document.Properties['labelSize'] barchart = barchart.As[Visualization]() myfont = barchart.LabelFont newfont = Font(myfont.Name,newsize) barchart.LabelFont = newfont Link to comment Share on other sites More sharing options...
David Law 2 Posted December 18, 2020 Author Share Posted December 18, 2020 Thanks Gaia. This is really helpful, just the solution I'm looking for. 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