Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How change the order property of a graphic by the macro?

I need change the order of a graphic when i press a button, is posible?

I have the next code in a function:

'First set a variable with the object type graphic

set obj = ActiveDocument.GetSheetObject("CH12")

'Then set the properties of the graphic

set p = obj.GetProperties

'Find the expressions

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



AND THEN??

i see "expr.ExpressionTypes(0).Order = 3" in a forum but not result

1 Solution

Accepted Solutions
Not applicable
Author

Hi Felipe,

i think that to change the graphic order you must change the order of dimension(s) not to the expression. Below is a quick example how to change the sorting of a chart to "Expression" with remove all other sorts: (example for each sorting can be found in ApiGuide.qvw

sub ChangeSorting

set chart=ActiveDocument.GetSheetObject("CH02")

set Prop = chart.GetProperties

set vars = Prop.Dimensions

for i = 0 to vars.Count-1

vars.Item(i).SortCriteria.SortByLoadOrder = 0

vars.Item(i).SortCriteria.SortByAscii = 0

vars.Item(i).SortCriteria.SortByFrequency = 0

vars.Item(i).SortCriteria.SortByLoadOrder = 0

vars.Item(i).SortCriteria.SortByNumeric = 0

vars.Item(i).SortCriteria.SortByState = 0

'These two dont work for pivot table

'vars.Item(i).SortCriteria.SortByYValue = 0

'vars.Item(i).SortCriteria.SortByApplicability = 0

vars.Item(i).SortCriteria.SortByExpression = 1

vars.Item(i).SortCriteria.Expression.v = "sum(Qty)"

next

chart.SetProperties Prop

end sub



Stefan

View solution in original post

2 Replies
Not applicable
Author

Hi Felipe,

i think that to change the graphic order you must change the order of dimension(s) not to the expression. Below is a quick example how to change the sorting of a chart to "Expression" with remove all other sorts: (example for each sorting can be found in ApiGuide.qvw

sub ChangeSorting

set chart=ActiveDocument.GetSheetObject("CH02")

set Prop = chart.GetProperties

set vars = Prop.Dimensions

for i = 0 to vars.Count-1

vars.Item(i).SortCriteria.SortByLoadOrder = 0

vars.Item(i).SortCriteria.SortByAscii = 0

vars.Item(i).SortCriteria.SortByFrequency = 0

vars.Item(i).SortCriteria.SortByLoadOrder = 0

vars.Item(i).SortCriteria.SortByNumeric = 0

vars.Item(i).SortCriteria.SortByState = 0

'These two dont work for pivot table

'vars.Item(i).SortCriteria.SortByYValue = 0

'vars.Item(i).SortCriteria.SortByApplicability = 0

vars.Item(i).SortCriteria.SortByExpression = 1

vars.Item(i).SortCriteria.Expression.v = "sum(Qty)"

next

chart.SetProperties Prop

end sub



Stefan

Not applicable
Author

Thanks Stefan, i will try, and thinking, you have the reason about the dimensions.