Jump to content

Script to create a drop down list that change the font size for bar chart label


David Law 2

Recommended Posts

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

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