Jump to content
  • This documentation is an older version of JasperReports Server Visualize.js Guide. View the latest documentation.

    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's named "data," it does not contain any data in the dashboard or reports, but rather 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 determines 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 parameters 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 parameters and the HTML displays a button when they're 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

    In JasperReports Server 6.1, the handling of dashboard hyperlinks changes. There is now a default behavior that makes sense for most types of hyperlinks and actions. There are several types of links:

    Reference – The reference link indicates an external source that is identified by a normal URL. The only expression required is the hyperlink reference expression. It's possible to specify additional parameters for this hyperlink type.
    LocalAnchor – To point to a local anchor means to create a link between two locations into the same document. It can be used, for example, to link the titles of a summary to the chapters to which they refer. To define the local anchor, it is necessary to specify a hyperlink anchor expression, which will have to produce a valid anchor name. It's possible to specify additional parameters for this hyperlink type.
    LocalPage – If instead of pointing to an anchor you want to point to a specific current report page, you need to create a LocalPage link. In this case, it is necessary to specify the page number you are pointing to by means of a hyperlink page expression (the expression has to return an Integer object). It's possible to specify additional parameters for this hyperlink type.
    RemoteAnchor – If you want to point to a particular anchor that resides in an external document, you use the RemoteAnchor link. In this case, the URL of the external file pointed to will have to be specified in the Hyperlink Reference Expression field, and the name of the anchor will have to be specified in the Hyperlink Anchor Expression field. It's possible to specify additional parameters for this hyperlink type.
    RemotePage – This link allows you to point to a particular page of an external document. Similarly, in this case the URL of the external file pointed to, will have to be specified in the Hyperlink Reference Expression field, and the page number will have to be specified by means of the hyperlink page expression. Some export formats have no support for hypertext links. It's possible to specify additional parameters for this hyperlink type.
    ReportExecution – This type of hyperlink is used to implement JasperServer’s drill-down feature. Page and anchor can be specified for the hyperlink type as well as additional special parameters such as _report, _anchor, _page, _output.
    AdHocExecution – This type of hyperlink represents an information about clicked point on chart reports generated from AdHoc Charts. It exposes names of measures and values of dimensions as parameters.
    Custom Hyperlink Type – A type of hyperlink that you can define entirely.

    And there are several types of link targets:

    Self – This is the default setting. It opens the link in the current window.
    Blank – Opens the target in a new window. Used for output formats such as HTML and PDF
    Top – Opens the target in the current window but outside any frames. Used for output formats such as HTML and PDF.
    Parent – Opens the target in the parent window (if available). Used for output formats such as HTML and PDF.
    Frame name – Always opens the target in the specified frame.

    The following table shows the new default action for each combination of link and target:

    Type Targets Self Blank Top Parent

    Reference

    (points to an external resource)

    Referenced URL is opened in an iframe on top of the report. Referenced url is opened in new tab. Referenced url is opened in same window. Referenced url is opened in parent frame for reports generated from AdHoc Charts.

    ReportExecution

    (points to JasperReports report)

    Referenced report is opened in same place through Viz.js (if hyperlink points to the same report, it's just gets updated with params/page/anchor). Referenced report is opened in new tab. Referenced report is opened in top frame (same window). Referenced report is opened in parent frame.

    LocalAnchor

    (points to an anchor in current report)

    Anchor is opened in same place through Viz.js. Referenced report anchor is opened in new browser tab. Referenced report anchor is opened in top frame (same window). Referenced report anchor is opened in parent frame.

    LocalPage

    (points to a page in current report)

    Page is opened in same place through Viz.js. Referenced report page is opened in new browser tab. Referenced report page is opened in top frame (same window). Referenced report page is opened in parent frame.

    RemoteAnchor

    (points to an anchor in remote document)

    Since remote anchor could be a link to resources like PDF or HTML, we have to open it in an iframe on top of the report. Referenced report anchor is opened in new browser tab. Referenced report anchor is opened in top frame (same window). Referenced report anchor is opened in parent frame.

    RemotePage

    (points to a page in remote document)

    Since remote page could be a link to resources like PDF or HTML we have to open it in an iframe on top of the report. Referenced report page is opened in new browser tab. Referenced report page is opened in top frame (same window). Referenced report page is opened in parent frame.

    AdHocExecution

    The hyperlink provides parameters, which are exposed to Filter Manager for additional wiring (beyond the scope of this document).

    The following code samples demonstrate the default handling of hyperlinks and the effect of defining overrides that remove the default handling. First the HTML for some buttons:

    And now some hyplerlink overrides:

    However, if your dashboards are designed for custom drill-down, you can still define custom link handling so your users can access more reports and more data. Be sure to modify your code to handle all three function parameters for function(ev, link, default), as shown in this updated code sample:

    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.


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...