The dashboard function runs dashboards on JasperReports Server and displays the result in a container that you provide. Dashboards are a collection of reports and widgets that you design on the server. Dashboards were entirely redesigned in JasperReports Server 6.0 to provide stunning data displays and seamless integration through Visualize.js.
This chapter contains the following sections:
• | Dashboard Properties |
• | Dashboard Functions |
• | Dashboard Structure |
• | Rendering a Dashboard |
• | Refreshing a Dashboard |
• | Using Dashboard Parameters |
• | Setting Dashboard Hyperlink Options |
• | Closing a Dashboard |
Dashboard Properties
The properties structure passed to the dashboard function is defined as follows:
Dashboard Functions
The dashboard function exposes the following functions:
Dashboard Structure
The Dashboard Data structure represents the rendered dashboard object manipulated by the dashboard function. Even though it is named "data," it does not contain any data in the dashboard or reports, but rather the data about the dashboard. For example, the Dashboard Data structure contains information about the items in the dashboard, called dashlets.
Rendering a Dashboard
To run a dashboard on the server and render it in Visualize.js, create a dashboard object and set its properties. Like rendering a report, the resource property determine which report to run, and the container property determines where it appears on your page.
The following code example shows how to define a dashboard ahead of time, then render it at a later time.
Refreshing a Dashboard
You can order the refresh or re-render of the dashboard , as well as cancel the refresh if necessary, for example if it takes too long.
Using Dashboard Parameters
As with reports, dashboard allow or require parameters that the user or your application can manipulate. First, you can discover the list of available parameters:
Then you read their values, modify them, and set new values. The dashboard then renders with the new input parameter values:
In the following example, a button resets the paramters to their default values by sending a null parameter set. First the HTML to define the container and the button:
And then the JavaScript to perform the action:
In another example, the script initializes the paramters and the HTML displays a button when they are ready to be applied:
And then the JavaScript to initialize the parameters and enable the button for the user:
You can create any number of user interfaces, database lookups, or your own calculations to provide the values of parameters. Your parameters could be based on 3rd party API calls that get triggered from other parts of the page or other pages in your app. When your dashboards can respond to dynamic events, they become truly embedded and much more relevant to the user.
Setting Dashboard Hyperlink Options
When your dashboards are designed for drill-down, your users can access more reports and more data.
Closing a Dashboard
When you want to reuse a container for other contents and free the dashboard resources, use the destroy function to close it.
Recommended Comments
There are no comments to display.