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: 
johanlindell
Partner - Creator II
Partner - Creator II

Show and hide charts via macro

I was struggling to show different charts when clicking on gauges for a dashboard with the ajax client and layers. There are some posts on working with layers that works fine in the IE-plugin client. But it does not work in the Ajax client.

This syntax goes like this - showing Chart1 over Chart 2:

ActiveDocument.GetSheetObject("CH01").SetLayer 1

ActiveDocument.GetSheetObject("CH02").SetLayer -1

So I tried to find a solution with hiding / showing the charts when clicking. There are plenty examples for text-boxes but this does not work for charts. And I had trouble finding a solution for charts - also in the API-guide.

This syntax is like this for showing a box and does not work for charts:

set LB = ActiveDocument.GetSheetObject("LB01")

set boxprop=LB.GetProperties

boxprop.Layout.Frame.Show.Always = false

boxprop.Layout.Frame.Show.Expression.v = "1=2"

LB.SetProperties boxprop

After some work and tests I found the macro syntax that works.

Hiding a chart:

set fd = BU.GetFrameDef

set CH = ActiveDocument.GetSheetObject("CH01")

fd.Show.Always = false

fd.Show.Expression.v = "1 = 2"

CH.SetFrameDef fd

Showing a chart:

set CH = ActiveDocument.GetSheetObject("CH01")

set fd = BU.GetFrameDef

fd.Show.Always = true

fd.Show.Expression.v = ""

CH.SetFrameDef fd

See attached a simple example

//Johan

2 Replies
Gysbert_Wassenaar

Why are you using macro's instead of conditional display expression, variables and actions to set the variables? Macro's may not always work, especially in the ajax client. See attached qvw


talk is cheap, supply exceeds demand
johanlindell
Partner - Creator II
Partner - Creator II
Author

Gysbert - that is indeed a better solution.

I just googled and found some examples of something similar - and then it didn't work. So I continued along the examples.

Regards

Johan