[148] Script to Maximize Visualization View

Script to Maximize Visualization View

Did you know that you can move or resize a control on your dashboard with a simple script? You might want to do this to give emphasis to certain visualizations or reduce the size of ones that are not important. You can add this script to the ‘on click event’ of any control, like a button to perform this action.

You can change the height/width as well as the top/left properties.

Here is the script to allow you to move controls around the dashboard and resize them programmatically.

table1.height = ??;
table1.width = ??;
table1.left = ??;
table1.top = ??;’

*replace table1 with the name of your control.

Be careful with View if you use a script like this to move and resize controls on a dashboard. Make sure your dashboard is Checked In or you are using Sandbox View as these sorts of changes via script are permanent otherwise. Changing these properties via script in View is the same as going over to the properties grid and making a change in Edit mode - the changes stick.

2 Likes

Now that there is the built-in Maximize option that users can get from the context menu is there a way to access this functionality using the JavaScript API? I would like to trigger the maximize functionality by click on a button for example and if possible also set the background that Dundas is picking for the background of the maximized chart.

1 Like

Hello StrangerForWhomISurelyDoNotKnow,

You call the maximize function using this approach:

var canvasService = this.getService("CanvasService");
var commandService = this.getService("CommandService");
commandService.executeCommand(canvasService.createModalViewCommand(chart1));

Maybe also use a layer with a covering rectangle to create a new background before you call this? And show the layer…

Seems that commandService also has an undo() command which I believe will reverse this - or just have your users push ESC.

3 Likes

Thanks @jeff for this answer.
I was trying to find this the other day, but the answer is definitely one that I couldn’t have found myself in a million years.

Glad to help! I think I will make a ‘tip video’ on this and expand the concept a bit further. It’s a neat one, and I think few people know how to do this.

Here’s the video walkthrough as well as an override for the background colour.

Amazing, thank you :slight_smile:

1 Like