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

How to access to a graph in a macro

Hello!

I need to add an expresion to a graph. I´ve been revised the classes and methods and I´ve found that tha classes GraphBasics and Graph have a method AddExpresion. The problem is that I can´t acces the graph. I can access with SheetObjects("CH01"), but the type returned is SheetObject, and iI need one of the previows ones. Is there a way of changing the types of a variable or to access directy to a graph???

Thanks.

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

I'm afraid you're wrong. Getting a reference with getsheetobject and then adding a dimension or expression works just fine for me. As does changing the charttype.


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Here's an example from the API Guide qvw:

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

chart.AddDimension "ProductType"

chart.AddExpression "sum(Amount)"

set p = chart.GetProperties

p.GraphLayout.FastChange.Bar = true

p.GraphLayout.FastChange.Line = true

p.GraphLayout.FastChange.Combo = true

p.GraphLayout.FastChange.Pie = true

p.GraphLayout.FastChange.Scatter = false

p.GraphLayout.FastChange.Straight = false

p.GraphLayout.FastChange.Pivot = false

p.ChartProperties.FastChangeInChart = true

chart.SetProperties p

chart.SetChartType  4       'line

You can change the first line into something lik set chart = ActiveDocument.GetSheetObject("CH01") to get a reference to an existing chart


talk is cheap, supply exceeds demand
Not applicable
Author

Hi

ActiveDocument.GetSheetObject("CH01") returns a SheetObject that hasn´t got the methods AddDimension, AddExpression or SetChartType. Those methods are from Graph, that is returned by CreateBarChart...

Finally I´ve used GetGraphs and getObjectId

Thx

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

I'm afraid you're wrong. Getting a reference with getsheetobject and then adding a dimension or expression works just fine for me. As does changing the charttype.


talk is cheap, supply exceeds demand
Not applicable
Author

Hello

Don´t be afraid

I´ve just tried it again and it works fine. I don´t know what can I do wrong before.

Thanks a lot.