Add a script to set the dashboard title


1. Overview

This article shows you how to add a Label component to a dashboard in order to display a title that changes dynamically.

Specifically, you will see how to add a script that changes the label text based on the current name of the dashboard. So if the dashboard is ever renamed by a designer, the title will still be correct when the dashboard is viewed.

The basic idea is to add a script to handle the dashboard's Ready action which is triggered whenever the dashboard is loaded and viewed.

2. Create a dashboard

For this example, create a new dashboard from the main menu.

Go to the status bar at the bottom and double click the name of the dashboard to edit it.

Type a new name Customer Orders 2015 and press ENTER.

Rename the dashboard
Rename the dashboard

2.1. Add a label component

Go to the toolbar, click Components, and then click Label to add a label component to the canvas.

Add a label component
Add a label component

With the label on the canvas selected, click the PROPERTIES tab.

Click Text to see text-related properties and make the following changes:

  • Set the Font Size to x-large.
  • Set the Font Weight to Bold.

Set the label's text-related properties
Set the label's text-related properties

3. Add a script

Click on the dashboard canvas, outside of any controls or components.

Click the PROPERTIES tab to see the properties of the dashboard.

Under Main \ ACTIONS, look for the dashboard's Ready action.

Click the plus sign button to add an empty script for handling this action.

Add a script to handle Ready action
Add a script to handle Ready action

Click script 1 to open the Script Editor.

In the editor, copy and paste the following JavaScript code.

label1.labelText =;

Then click Build to check for any script errors. (There's no need to save because the Script Editor auto-saves as you type.)

Script Editor
Script Editor

4. Test the script

The Ready action is triggered when the dashboard is reloaded (e.g. in a new tab or when the browser is refreshed), but not when switching between Edit and View mode.

So, to test the script, go to the toolbar and click Sandbox View which will load the dashboard in a new browser window.

Use Sandbox View to test
Use Sandbox View to test

5. See also

Dundas Data Visualization, Inc.
500-250 Ferrand Drive
Toronto, ON, Canada
M3C 3G8

North America: 1.800.463.1492
International: 1.416.467.5100

Dundas Support Hours: 7am-6pm, ET, Mon-Fri