Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Contributor 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


2 Replies

Re: Show and hide charts via macro

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
Contributor II

Re: Show and hide charts via macro

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.



Community Browser