Bucket properties are user defined key/value pairs associated to a category or series level. The name of the property can be decided by the user, and the value can be defined by using an expression.
|
Defining Bucket Properties for HTML5 Chart Hyplerlinking |
Let's define a new property, called country_url, storing a link specific to the country (something like http://en.wikipedia.org/wiki/Italy and use this link in our chart measure hyperlink definition so that, when a user clicks on a column, the link of the country that the column references is opened.
| 1. | Create a new bucket property for the Country category level, with the following settings: |
| • | Property name: country_link |
| 2. | Once done, open up the configuration dialog of our measure, move to Advanced Properties, and double click the HyperlinkReference property, and set as value the newly create country_link bucket propert |
|
Configuring Measure Properties to set the HyperlinkReference Value |
| 3. | Save the report and preview. Now, when clicking on a column, a web page on Wikipedia related to our country should open up. |
By using bucket properties, it is possible to create links connected to a dimension. In this case it was the Country dimension (the Country category), but the same approach can be used to create a link related to series.
This mechanism, anyway, is still not powerful enough to create an URL that combines more dimension values at the same time, at least when those values coming from different dimensions need to be used in a single expression to form a link (a later section explains why this doesn't pose a problem in case of a hyperlink of type ReportExecution when the values can be passed as individual hyperlink parameters).
The only expression that can be created by accessing all the dimension values at the same time is a measure, so we can create a measure to hold our very complex hyperlink, and refer it in the hyperlinkReference property.
To make this example a little bit more useful, and see how we can really use in hyperlink information coming form different dimensions, let's add an extra dimension called year, so the chart can display the number of orders placed in a specific country in a specific year. Then we can create a hyperlink that contains both the country and the year.
| 1. | Add the new dimension by creating a new series level configured as follow: |
| • | Expression: YEAR( $F{ORDERDATE} ) |
|
Editing Series Level to Define Buckets |
Now,for each country, the chart shows the number of orders split by year.
|
Bar Chart with Order Numbers Split by Year |
Let's create a new measure to build our URL string. Please note that usually measures are designed to hold numeric values, most of the time the result of some aggregation function (in our example we show the count of orders). But a measure can actually be anything; in our case it's a string built using an expression like the following:
| • | Hidden: true (it is very important to check the checkbox, since we are not going to display this measure, it would not make sense since it is not numeric) |
| • | Value Expression: "http://en.wikipedia.org/wiki/" + $F{SHIPCOUNTRY} + "/" + YEAR( $F{ORDERDATE}) |
| • | Value Class Name: java.lang.String |
|
Defining the URL to Open when the Measure is Clicked |
The most important things to note are 3:
| • | the measure is marked as hidden |
| • | the calculation type is set to Nothing |
| • | the class of the measure is String (accordingly to what the expression produces) |
The expression produces a String which represent an URL having both a reference to the country and the year of the order.
Now, let's use this measure.
| 2. | Open the # of orders measure to edit the hyperlinkReference and set as value the measure we just created. |
|
Editing the hyperlinkReference to use a Measure Value |
Now, each column, slice, bar, column section in stacked column chart points to the country/year the object is representing.
Recommended Comments
There are no comments to display.