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

Hiding Reference Lines

Is there a way to create a check box that you can turn on and off a reference line on a chart?

~Norman Rea

1 Solution

Accepted Solutions
Not applicable
Author

There is standard functionality to conditionally show/hide refrence lines, so I really wouldn't recommend doing this via a macro.

Please see attached

Hope that helps

Joe

View solution in original post

10 Replies
datanibbler
Champion
Champion

Hi,

sure there is. You can wrap the expression for the line inside an IF_expression making it dependent on the value of a variable.

I would advise you to create a "development_variable" that you can use in any app you create and that you can toggle, thus turning such things on or off at will.

HTH

Not applicable
Author

you have some example code for me to understand?

~Norm

buzzy996
Master II
Master II

ur looking for this?

ref line.PNG

datanibbler
Champion
Champion

Well, just use the usual

>> SET v_Dev = 1 <<

to initialize the variable.

Then you can wrap any expression in an IF_clause like

>> = IF(v_Dev = 1,

) <<

You can also make the visibility of any object dependent on that variable. And you can add a button with the expression (to set a variable_value) >> = v_Dev * -1 << - that way, it will be either 1 or -1 and you can toggle it easily.

sunny_talwar

Hahahaha you are right. It makes me feel so stupid that I thought it was not possible,

Best,

Sunny

robert_mika
Master III
Master III

..or more advance way.

Add this to Edit Module window and add to buttons

One will create line in your chart the other will remove it

(Change the bit in Green to your values)

sub AddRef

set chart = ActiveDocument.GetSheetobject("CH01")

col = ActiveDocument.GetApplication.GetSolidColorArea(255,0,0)  'red

chart.AddRefLine "50",2,col    'red at 50 on primary y

set p = chart.GetProperties

set rl = p.ChartProperties.RefLines.Item(0)

rl.Style = 0           'solid

chart.SetProperties p

End sub

Sub RemoveRef

set Graph = ActiveDocument.GetSheetObject("CH01")

Graph.RemoveRefLine 0

End sub

Not applicable
Author

There is standard functionality to conditionally show/hide refrence lines, so I really wouldn't recommend doing this via a macro.

Please see attached

Hope that helps

Joe

buzzy996
Master II
Master II

try this way also,

ref cond.PNG

Not applicable
Author

Where did you define you variable