To initialize a single dashboard you need to create a Dashboard object and pass valid options as shown below:
var dashboard = new Dashboard(options);
Where the options are a json object with the following specifications
Options
Dashboard methods
To add a new Widget, for example:
myDashboard.addWidget('myWheaterWidget', 'Weather', {
WOEID: 395269
});
For details you can check the widgets topic
To subscribe an event in this dashboard you can do the following:
myDashboard.subscribe('myEvent', function() {
console.log('event fired!');
});
To publish an event in this dashboard you can do the following:
myDashboard.publish('myEvent');
To initialize a multiple dashboard you need to create a DashboardSet object and pass valid options as shown below:
var myDashboardSet = new DashboardSet();
DashboardSet methods
To add a new Dashboard:
myDashboardSet.addDashboard(name, options)
Where name is a string with the name of the dashboard and options is a json object with the same format of the options of the Dashboard object.
To get a Dashboard from the DashboardSet object:
myDashboardSet.getDashboard(name)
To add a button on the overlay menu that runs arbitrary javascript code, for example:
myDashboardSet.addAction('Go to Google', function() {
window.location.href = 'https://google.com/';
})
Swap between dashboards
Manual
To swap between dashboards you need to press the ctrl key to display the menu.
Automatic
To swap the dashboards automatically you can set the option rollingChoices as true when the dashboardSet is created as follows:
myDashboardSet = new DashboardSet({
rollingChoices: true
}),
Then you can select the rolling time in the ctrl menu. Or you can add the parameter roll=<value> to the URL, where the value has to be specified in microseconds, for example:
http://127.0.0.1:8000/dashboard/#/main?roll=3000
Dashboard Events
Each single dashboard publishes a shown or hidden event when the dashboard are loaded or unloaded, you can use it as follows:
myDashboard = myDashboardSet.addDashboard('New Dashboard');
myDashboard.subscribe('shown', function() {alert('new dashboard shown')});
myDashboard.subscribe('hidden', function() {alert('new dashboard hidden')});