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: 
Not applicable

How to set read-only property for particular charts via a macro?

Dear users,

I have four different scatter-charts on top of eachother. Each scatter-chart layer can be called to the foreground by pressing on its corresponding button which executes a macro. This macro simply calls the SetLayer method, and pushes other layers to the back and brings the specific layer to the front.

when a users wants to make a selection in the chart, it should only affect the chartlayer which is on top. I was thinking of a way to set the layers in the back to ready-only. However, I did not find any method to achieve this via VBscript. Am I overlooking something, or is there another way for achieving this?

This is my script:

Sub setOnTop_TW1Plot

          ActiveDocument.GetSheetObject("CH89").SetLayer -7

          ActiveDocument.GetSheetObject("CH90").SetLayer -6

          ActiveDocument.GetSheetObject("CH91").SetLayer -5

          'ActiveDocument.GetSheetObject("CH67").SetLayer -1

          ActiveDocument.GetSheetObject("CH67").SetLayer 0

End Sub

Sub setOnTop_TW2Plot

          ActiveDocument.GetSheetObject("CH91").SetLayer -7

          ActiveDocument.GetSheetObject("CH90").SetLayer -6

          ActiveDocument.GetSheetObject("CH67").SetLayer -5

          'ActiveDocument.GetSheetObject("CH67").SetLayer -1

          ActiveDocument.GetSheetObject("CH89").SetLayer 0

End Sub

Sub setOnTop_TW3Plot

          ActiveDocument.GetSheetObject("CH91").SetLayer -7

          ActiveDocument.GetSheetObject("CH89").SetLayer -6

          ActiveDocument.GetSheetObject("CH67").SetLayer -5

          'ActiveDocument.GetSheetObject("CH67").SetLayer -1

          ActiveDocument.GetSheetObject("CH90").SetLayer 0

End Sub

Sub setOnTop_TW4Plot

          ActiveDocument.GetSheetObject("CH90").SetLayer -7

          ActiveDocument.GetSheetObject("CH89").SetLayer -6

          ActiveDocument.GetSheetObject("CH67").SetLayer -5

          'ActiveDocument.GetSheetObject("CH67").SetLayer -1

          ActiveDocument.GetSheetObject("CH91").SetLayer 0

End Sub

Added the qvw

1 Solution

Accepted Solutions
Not applicable
Author

Nazeem,

it appears your charts aren't actually set to use the states TW1-TW4 which you defined.

Capture1.JPG

but you are using the alternate state within the set analysis. the dimensions are shared (all of them just using the default inherited state), so when you filter one chart, it impacts all the other ones, too. i think the fact that the charts are on top of each other has nothing to do with the anomaly as your selection would only apply to the top object. it's the shared dimension that's causing the filtering to impact all objects. try completely dissociating the charts via setting them to the alternate states at the object level and not just in the set analysis.

View solution in original post

5 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Here is the code

    

 

Sub ReadOnly

set chart = ActiveDocument.GetSheetObject("CH03")
set p = chart.GetProperties
p.ReadOnly = true
chart.SetProperties p

End Sub

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Kaushik Solanki wrote:

Hi,

     Here is the code

 

Sub ReadOnly

set chart = ActiveDocument.GetSheetObject("CH03")
set p = chart.GetProperties
p.ReadOnly = true
chart.SetProperties p

End Sub

Regards,

Kaushik Solanki

Hi,

I used your code and came up with the following.

Sub setOnTop_TW1Plot

           'TW1 charts (on top)

           'TW1 Gas regression chart

           set TW1_gasReg = ActiveDocument.GetSheetObject("CH123")

           TW1_gasReg.SetLayer 0

           set TW1_gasReg_props = TW1_gasReg.GetProperties

           TW1_gasReg_props.ReadOnly = false

           TW1_gasReg.SetProperties TW1_gasReg_props

           'TW1 Gas chart

           set TW1_gas = ActiveDocument.GetSheetObject("CH67")

           TW1_gas.SetLayer -1

           set TW1_gas_props = TW1_gas.GetProperties

           TW1_gas_props.ReadOnly = false

           TW1_gas.SetProperties TW1_gas_props

           'TW2 charts

           'TW2 Gas regression chart

           set TW2_gasReg = ActiveDocument.GetSheetObject("CH127")

           TW2_gasReg.SetLayer -2

           set TW2_gasReg_props = TW2_gasReg.GetProperties

           TW2_gasReg_props.ReadOnly = true

           TW2_gasReg.SetProperties TW2_gasReg_props

           'TW2 Gas chart

           set TW2_gas = ActiveDocument.GetSheetObject("CH128")

           TW2_gas.SetLayer -3

           set TW2_gas_props = TW2_gas.GetProperties

           TW2_gas_props.ReadOnly = true

           TW2_gas.SetProperties TW2_gas_props

           'TW3 charts

           'TW3 Gas regression chart

           set TW3_gasReg = ActiveDocument.GetSheetObject("CH132")

           TW3_gasReg.SetLayer -4

           set TW3_gasReg_props = TW3_gasReg.GetProperties

           TW3_gasReg_props.ReadOnly = true

           TW3_gasReg.SetProperties TW3_gasReg_props

           'TW3 Gas chart

           set TW3_gas = ActiveDocument.GetSheetObject("CH131")

           TW3_gas.SetLayer -5

           set TW3_gas_props = TW3_gas.GetProperties

           TW3_gas_props.ReadOnly = true

           TW3_gas.SetProperties TW3_gas_props

           'TW4 charts

           'TW4 Gas regression chart

           set TW4_gasReg = ActiveDocument.GetSheetObject("CH135")

           TW4_gasReg.SetLayer -6

           set TW4_gasReg_props = TW4_gasReg.GetProperties

           TW4_gasReg_props.ReadOnly = true

           TW4_gasReg.SetProperties TW4_gasReg_props

           'TW4 Gas chart

           set TW4_gas = ActiveDocument.GetSheetObject("CH136")

           TW4_gas.SetLayer -7

           set TW4_gas_props = TW4_gas.GetProperties

           TW4_gas_props.ReadOnly = true

           TW4_gas.SetProperties TW4_gas_props

End Sub

Sub setOnTop_TW2Plot

           'TW2 charts (on top)

           'TW2 Gas regression chart

           set TW2_gasReg = ActiveDocument.GetSheetObject("CH127")

           TW2_gasReg.SetLayer 0

           set TW2_gasReg_props = TW2_gasReg.GetProperties

           TW2_gasReg_props.ReadOnly = false

           TW2_gasReg.SetProperties TW2_gasReg_props

           'TW2 Gas chart

           set TW2_gas = ActiveDocument.GetSheetObject("CH128")

           TW2_gas.SetLayer -1

           set TW2_gas_props = TW2_gas.GetProperties

           TW2_gas_props.ReadOnly = false

           TW2_gas.SetProperties TW2_gas_props

           'TW1 charts

           'TW1 Gas regression chart

           set TW1_gasReg = ActiveDocument.GetSheetObject("CH123")

           TW1_gasReg.SetLayer -2

           set TW1_gasReg_props = TW1_gasReg.GetProperties

           TW1_gasReg_props.ReadOnly = true

           TW1_gasReg.SetProperties TW1_gasReg_props

           'TW1 Gas chart

           set TW1_gas = ActiveDocument.GetSheetObject("CH67")

           TW1_gas.SetLayer -3

           set TW1_gas_props = TW1_gas.GetProperties

           TW1_gas_props.ReadOnly = true

           TW1_gas.SetProperties TW1_gas_props

           'TW3 charts

           'TW3 Gas regression chart

           set TW3_gasReg = ActiveDocument.GetSheetObject("CH132")

           TW3_gasReg.SetLayer -4

           set TW3_gasReg_props = TW3_gasReg.GetProperties

           TW3_gasReg_props.ReadOnly = true

           TW3_gasReg.SetProperties TW3_gasReg_props

           'TW3 Gas chart

           set TW3_gas = ActiveDocument.GetSheetObject("CH131")

           TW3_gas.SetLayer -5

           set TW3_gas_props = TW3_gas.GetProperties

           TW3_gas_props.ReadOnly = true

           TW3_gas.SetProperties TW3_gas_props

           'TW4 charts

           'TW4 Gas regression chart

           set TW4_gasReg = ActiveDocument.GetSheetObject("CH135")

           TW4_gasReg.SetLayer -6

           set TW4_gasReg_props = TW4_gasReg.GetProperties

           TW4_gasReg_props.ReadOnly = true

           TW4_gasReg.SetProperties TW4_gasReg_props

           'TW4 Gas chart

           set TW4_gas = ActiveDocument.GetSheetObject("CH136")

           TW4_gas.SetLayer -7

           set TW4_gas_props = TW4_gas.GetProperties

           TW4_gas_props.ReadOnly = true

           TW4_gas.SetProperties TW4_gas_props

End Sub

Sub setOnTop_TW3Plot

          'TW3 charts (on top)

           'TW3 Gas regression chart

           set TW3_gasReg = ActiveDocument.GetSheetObject("CH132")

           TW3_gasReg.SetLayer 0

           set TW3_gasReg_props = TW3_gasReg.GetProperties

           TW3_gasReg_props.ReadOnly = false

           TW3_gasReg.SetProperties TW3_gasReg_props

           'TW3 Gas chart

           set TW3_gas = ActiveDocument.GetSheetObject("CH131")

           TW3_gas.SetLayer -1

           set TW3_gas_props = TW3_gas.GetProperties

           TW3_gas_props.ReadOnly = false

           TW3_gas.SetProperties TW3_gas_props

           'TW1 charts

           'TW1 Gas regression chart

           set TW1_gasReg = ActiveDocument.GetSheetObject("CH123")

           TW1_gasReg.SetLayer -2

           set TW1_gasReg_props = TW1_gasReg.GetProperties

           TW1_gasReg_props.ReadOnly = true

           TW1_gasReg.SetProperties TW1_gasReg_props

           'TW1 Gas chart

           set TW1_gas = ActiveDocument.GetSheetObject("CH67")

           TW1_gas.SetLayer -3

           set TW1_gas_props = TW1_gas.GetProperties

           TW1_gas_props.ReadOnly = true

           TW1_gas.SetProperties TW1_gas_props

           'TW2 charts

           'TW2 Gas regression chart

           set TW2_gasReg = ActiveDocument.GetSheetObject("CH127")

           TW2_gasReg.SetLayer -4

           set TW2_gasReg_props = TW2_gasReg.GetProperties

           TW2_gasReg_props.ReadOnly = true

           TW2_gasReg.SetProperties TW2_gasReg_props

           'TW2 Gas chart

           set TW2_gas = ActiveDocument.GetSheetObject("CH128")

           TW2_gas.SetLayer -5

           set TW2_gas_props = TW2_gas.GetProperties

           TW2_gas_props.ReadOnly = true

           TW2_gas.SetProperties TW2_gas_props

           'TW4 charts

           'TW4 Gas regression chart

           set TW4_gasReg = ActiveDocument.GetSheetObject("CH135")

           TW4_gasReg.SetLayer -6

           set TW4_gasReg_props = TW4_gasReg.GetProperties

           TW4_gasReg_props.ReadOnly = true

           TW4_gasReg.SetProperties TW4_gasReg_props

           'TW4 Gas chart

           set TW4_gas = ActiveDocument.GetSheetObject("CH136")

           TW4_gas.SetLayer -7

           set TW4_gas_props = TW4_gas.GetProperties

           TW4_gas_props.ReadOnly = true

           TW4_gas.SetProperties TW4_gas_props

End Sub

Sub setOnTop_TW4Plot

          'TW4 charts (on top)

           'TW4 Gas regression chart

           set TW4_gasReg = ActiveDocument.GetSheetObject("CH135")

           TW4_gasReg.SetLayer 0

           set TW4_gasReg_props = TW4_gasReg.GetProperties

           TW4_gasReg_props.ReadOnly = false

           TW4_gasReg.SetProperties TW4_gasReg_props

           'TW4 Gas chart

           set TW4_gas = ActiveDocument.GetSheetObject("CH136")

           TW4_gas.SetLayer -1

           set TW4_gas_props = TW4_gas.GetProperties

           TW4_gas_props.ReadOnly = false

           TW4_gas.SetProperties TW4_gas_props

           'TW1 charts

           'TW1 Gas regression chart

           set TW1_gasReg = ActiveDocument.GetSheetObject("CH123")

           TW1_gasReg.SetLayer -2

           set TW1_gasReg_props = TW1_gasReg.GetProperties

           TW1_gasReg_props.ReadOnly = true

           TW1_gasReg.SetProperties TW1_gasReg_props

           'TW1 Gas chart

           set TW1_gas = ActiveDocument.GetSheetObject("CH67")

           TW1_gas.SetLayer -3

           set TW1_gas_props = TW1_gas.GetProperties

           TW1_gas_props.ReadOnly = true

           TW1_gas.SetProperties TW1_gas_props

           'TW2 charts

           'TW2 Gas regression chart

           set TW2_gasReg = ActiveDocument.GetSheetObject("CH127")

           TW2_gasReg.SetLayer -4

           set TW2_gasReg_props = TW2_gasReg.GetProperties

           TW2_gasReg_props.ReadOnly = true

           TW2_gasReg.SetProperties TW2_gasReg_props

           'TW2 Gas chart

           set TW2_gas = ActiveDocument.GetSheetObject("CH128")

           TW2_gas.SetLayer -5

           set TW2_gas_props = TW2_gas.GetProperties

           TW2_gas_props.ReadOnly = true

           TW2_gas.SetProperties TW2_gas_props

           'TW3 charts (on top)

           'TW3 Gas regression chart

           set TW3_gasReg = ActiveDocument.GetSheetObject("CH132")

           TW3_gasReg.SetLayer -6

           set TW3_gasReg_props = TW3_gasReg.GetProperties

           TW3_gasReg_props.ReadOnly = true

           TW3_gasReg.SetProperties TW3_gasReg_props

           'TW3 Gas chart

           set TW3_gas = ActiveDocument.GetSheetObject("CH131")

           TW3_gas.SetLayer -7

           set TW3_gas_props = TW3_gas.GetProperties

           TW3_gas_props.ReadOnly = true

           TW3_gas.SetProperties TW3_gas_props

End Sub

However, when I make a selection in the chart which is on top, it still affects all other charts. Even tough the underlying charts are having the property Read-Only to true.

Capture.PNG

In the example above, the blue chart is the chart which is on top and is not set to read-only. The red chart is set to readonly. However, when I make a selection inside the chart, it still affects both charts. Thus not only the blue chart.

When I deselect the option to show multiple charts (i.e only select the red chart, but still with the blue chart as te active one) then the red chart isn't affected by the selection.

Do you know where the problem lies?


Not applicable
Author

Hi,

Setting a chart as read only will prevent any selection being made on that chart - it will not (as far as I am aware) prevent selections made elsewhere in the document from affecting the chart itself.

What you want (based on my understanding) is to dissociate the cart in the foreground from everything else in the document.

You could try exploring the 'detach' option, which can be done by the users on demand - not really explored if this can be set programmatically,

Another option (probably easier to implement) is to use alternate states (Qlikview 11 onwards - part of new comparative analysis feature) - for multiple charts independent of each other then you set up multiple states and designate one per chart - effectively have several independent sets/buckets.

Regards,

Alex

Not applicable
Author

Thank you for your reply.

My situation is as follows:

I have 4 scatter charts on top of eachother. Let's call them TW1 to TW4.
When a user clicks on a textobject named TW1, the TW1 must be set to the foreground. When a user wants to make a selection directly  on the chart (thus, making a selection inside the chart) it should only affect the TW1-chart. The rest of the charts must remain the same (thus the selection must not be applied to the other charts which are at the bottom). The same principle applies to TW2 to TW4.

I'm aware of the alternate states functionaliteit. In fact, each scatterplot shows a selection made with objects in a specific state. For example, chart 1 shows the result of the selection made with objects which has the state TW1. And so fort.  See my attached Qvw.

Not applicable
Author

Nazeem,

it appears your charts aren't actually set to use the states TW1-TW4 which you defined.

Capture1.JPG

but you are using the alternate state within the set analysis. the dimensions are shared (all of them just using the default inherited state), so when you filter one chart, it impacts all the other ones, too. i think the fact that the charts are on top of each other has nothing to do with the anomaly as your selection would only apply to the top object. it's the shared dimension that's causing the filtering to impact all objects. try completely dissociating the charts via setting them to the alternate states at the object level and not just in the set analysis.