Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Move object to top with a button and layers

I'm looking to add multiple charts to a single page but would like them to all be the exact same size and in the exact same location.  I would then like a button or multiple buttons that bring the chart object to the top when the button is clicked.  Essentially like you would use a z-index in CSS. 

Any guideance would be great.  I've searched and I'm coming up with nothing.  Mabye I'm not searching on the right terms. 

Thank you!!!

2 Replies
msteedle
Luminary Alumni
Luminary Alumni

There is not currently an action that supports changing the X and Y values for the location of an object.

There is, however, a function for it in the API called SetRect, but based on what it does I am not sure it would work in AJAX.

rem ** move all objects on active sheet 20 pixels down and 15 right **

set sh = ActiveDocument.ActiveSheet

for i = 0 to sh.NoOfSheetObjects-1

    set obj = sh.SheetObjects(i)

    pos = obj.GetRect

    pos.Top = pos.Top + 20

    pos.Left = pos.Left + 15

    obj.SetRect pos

next

You could also accomplish it using multiple copies of the chart objects that are conditionally visible based on the behavior of your buttons.

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

I'd recommend using Hide/Show conditions over the idea of keeping all the objects "visible" and playing with the layers via macros, for the following reasons:

1. All the objects that are visible, will get calculated with every selections and virtually with every click, disregarding the layers. You are adding a lot of performance overhead for no benefit.

2. You can arrange your show/hide conditions to be driven by a variable, and the buttons could drive changing the value of the variable using actions, which is MUCH better than using VBScript macros.

cheers,

Oleg