Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

set label in graph expression in macro

Hello

I have a macro that adds expressions dinamicaly. I need the expressions added had a label.

How can I set a label in a graph´s expression in a macro???

Thanks

Muy buenas

Tengo una macro que añade las expresiones de un gráfico dinámicamente cada vez que recargamos el script. En dichas expresiones, necesito que en vez de la fórmula de la expresión me muestre una etiqueta.

¿Cómo puedo hacer que muestre una etiqueta?

Muchas gracias.

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Here's an example from the QV11 com api:

set chart = ActiveDocument.ActiveSheet.CreateStraightTable

chart.AddDimension "Customer"

chart.AddDimension "ProductType"

chart.AddExpression "sum(Amount)"

set cp = chart.GetProperties

set expr = cp.ExpressionVisuals(0)

expr.Label.v = "Sales"

expr.LabelAdjust = 2

chart.SetProperties cp

The lines in blue are what you're looking for. The example creates a new chart, but for an existing chart you can use activedocument.getsheetobject("ObjectID")


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Here's an example from the QV11 com api:

set chart = ActiveDocument.ActiveSheet.CreateStraightTable

chart.AddDimension "Customer"

chart.AddDimension "ProductType"

chart.AddExpression "sum(Amount)"

set cp = chart.GetProperties

set expr = cp.ExpressionVisuals(0)

expr.Label.v = "Sales"

expr.LabelAdjust = 2

chart.SetProperties cp

The lines in blue are what you're looking for. The example creates a new chart, but for an existing chart you can use activedocument.getsheetobject("ObjectID")


talk is cheap, supply exceeds demand
Not applicable
Author

This is the solution

set chart = ActiveDocument.ActiveSheet.CreateStraightTable

chart.AddDimension "Customer"

chart.AddDimension "ProductType"

chart.AddExpression "sum(Amount)"

set cp = chart.GetProperties

set expr = cp.Expressions.Item(0).Item(0).Data.ExpressionVisual

expr.Label.v = "Sales"

chart.SetProperties cp