Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Limit Legend (characters) in a Bar chart using Macro

Hi,

Can someone tell me how I can limit the number of characters in legends in a bar chart using macro? (Basically set the value which can be accessed using Properties > Presentation > Legend > Limit Legend. )

Checked the available APIs, but couldn't find any relevant API.

3 Replies
Not applicable
Author

Hi Balaji,

may be you can define the space area of your legend to get your goal.

set Graph = ActiveDocument.Sheets("Main").CreateBarChart

Graph.AddDimension "ProductType"

Graph.AddDimension "Customer"

Graph.AddExpression "sum(Amount)"

set p = Graph.GetProperties

set leg = p.ChartProperties.Legend

leg.DockedPosition = 4       'free floating

leg.Position.Top = 100

leg.Position.Left = 100

leg.Position.Height = 200

leg.Position.Width = 200

leg.OnTop = true

leg.UserSized = true

Graph.SetProperties p

Regards

Corrado.

Not applicable
Author

Found out the answer, need to use the API MaxStringLength to limit the number of characters in a chart.

Not applicable
Author

Hi,

Could you please share the code that worked for you? I'm working on something similar (displaying the legend, on/off).

thanks!