Working with Bucket Properties and Hidden Measures
Bucket properties are user defined key/value pairs associated with a category or series level. The user can name the property and define the value using an expression.
![jss-hyperlink-cat-level-bucket-prop_559x539.png.7f103ea66e2a31d5146ed5bd1deeaaf0.png](https://community.jaspersoft.com/applications/core/interface/js/spacer.png) |
Defining Bucket Properties for HTML5 Chart Hyperlinking |
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 and use the following settings: |
| • | Property name: country_link |
| 2. | Open the configuration dialog of your measure, move to Advanced Properties, and double click the HyperlinkReference property. |
| 3. | Set the Use a bucket property value to the newly created property: country_link. |
![jss-hyperlink-bucket-prop-value_318x339.png.c03761d09142624481ced8141517f91f.png](https://community.jaspersoft.com/applications/core/interface/js/spacer.png) |
Configuring Measure Properties to set the HyperlinkReference Value |
| 5. | Save the report and preview. Now, when you click a column, you should link to a Wikipedia page related to our country. |
Using bucket properties, you can 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.
To make this example a little bit more useful, and to see how we can really use hyperlink information 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 shown below: |
| • | Expression: YEAR( $F{ORDERDATE} ) |
![jss-hyperlink-series-level-bucket-info_357x235.png.a28a26359ef1e35d89d558f941fcc455.png](https://community.jaspersoft.com/applications/core/interface/js/spacer.png) |
Editing Series Level to Define Buckets |
Now, for each country, the chart shows the number of orders split by year.
![jss-hyperlink-greenblue-col-countries_429x282.png.325590c6e331c4c37bc8fcca368ce569.png](https://community.jaspersoft.com/applications/core/interface/js/spacer.png) |
Bar Chart with Order Numbers Split by Year |
Let's create a new measure to build our URL string. Measures are usually 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, because we are not going to display this measure, it would not make sense as it's not numeric) |
| • | Value Expression: "http://en.wikipedia.org/wiki/" + $F{SHIPCOUNTRY} + "/" + YEAR( $F{ORDERDATE}) |
| • | Value Class Name: java.lang.String |
![jss-hyperlink-url-measure_631x298.png.3ce00f932d1ad61da2fa09828eb62e41.png](https://community.jaspersoft.com/applications/core/interface/js/spacer.png) |
Defining the URL to Open when the Measure is Clicked |
The most important things to note are:
| • | 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 that represent a URL with a reference to both 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 the measure we just created as the value. |
![jss-hyperlink-measure-value_319x339.png.dc0fda6736399edd3f2ccc2ea8524917.png](https://community.jaspersoft.com/applications/core/interface/js/spacer.png) |
Editing the hyperlinkReference to use a Measure Value |
Now, each column, slice, bar, and column section in the stacked column chart points to the country and year the object is representing.
Recommended Comments
There are no comments to display.