You can use a variable to change the text color of the values, effectively hiding or showing them. See attached example.
salestodate53.qvw 157.2 K
The button has an action assigned to it to change the value of the vShowValues variable. The chart uses the value of the variable for the text color of the values. So if the button changes the value it's immediatly changed in the chart too. There's no document or sheet trigger involved.
The expression for the text color is black($(vShowValues)). The variable vShowValues is used for the alpha parameter of the black() color function. It determines how solid the color is. black(0) is totally transparant, black(255) is solid black.
The formula =(not vShowValues)*-255 flips the value of the variable between 0 and 255. It treats vShowValues as a boolean. If it has the value 0 then not vShowValues returns -1, if it has a value other than 0 it returns 0. By multiplying the result of not vShowValues (0 or -1) with -255 I get either 0 or 255.
The way I usually do is that I actually create 2 charts and a list box.
Say you want to view the values on data point:
- Add a table in your script as follows:
LOAD * INLINE [
- Create a listbox (checkbox) with ShowVal
- create a chart with value on datapoint. Add a condition on the layout: if(ShowVal='Show values',1,0)
- copy the first chart but untick show value on data point and add the condition: if(ShowVal<>'Show values',1,0)
If you're using Qlikview 11, no need to have 2 charts. Just us the conditional expressions.
That would work