Change bar segment labels from percentage to value

# barChart is a BarChart Visualizaiton script parameter
# labelInformationType is an integer document property script parameter with values 0|1 for pct or value
from Spotfire.Dxp.Application.Visuals import BarChart
barChart.As[BarChart]().SegmentLabelInformationType = labelInformationType 


# if you need to toggle from percantage to value, you can do this too:
from Spotfire.Dxp.Application.Visuals import BarChart, BarChart,LabelInformationType
barChart = barChart.As[BarChart]()
barChart.SegmentLabelInformationType = LabelInformationType.Value if barChart.SegmentLabelInformationType==LabelInformationType.Percentage else LabelInformationType.Percentage

2 comments:

Aditya walia said...

Another way of doing this.

from Spotfire.Dxp.Application.Visuals import BarChart,LabelInformationType
barChart=barChart.As[BarChart]()
if barChart.SegmentLabelInformationType==LabelInformationType.Percentage:
barChart.SegmentLabelInformationType=LabelInformationType.Value
else:
barChart.SegmentLabelInformationType=LabelInformationType.Percentage

Jose Leviaguirre said...

Thanks Aditya for your suggestion. I added that option on the post.