I. Overview
Previously introduced the linkage between reports and charts, that is, clicking on the data in the report to make the category axis data or series value of the chart change accordingly. Then if you click on the name of the report data column, how to make the chart's series name or category axis change dynamically? The effect is as follows:
II. Idea
Dynamically display the series name and category axis of the chart, then the chart can only use the cell dataset, only need to make the cell dynamically display the data column, in the ds1.select() and ds1.group() function use chapters introduce the ds1.group() method to get the data column in the dataset. Here we pass the data column name to the function in the form of a dynamic parameter, so that the data of the data column is dynamically displayed in the cell, and then the chart data source It comes from the dynamically changing cell.
III. Example
1. Create a dataset
Create a blank template and add the dataset ds1: SELECT * FROM SALES_BASIC.
2. Template design
1) The realization of dynamic data columns
Add a new template parameter col, the default value is "Salesperson", the heading cell B1 directly uses the formula =$col, and the dynamic data column value cell B2 is input using the formula =ds1.group($col,,true) , The main body design of the report is as follows:
Note: Cell B2 is the series name of the chart (dynamic change), the parent cell is A2, cell A2 is the classification axis data of the display chart, cell C2 is the series value of the chart, and the sales are summed according to cell B2 Change with change (dynamic change).
Another: The formula of ds1.group($col,,true) means to get all the values of the col parameter value data column in the ds1 data set, and merge all the same items. Note that there is a blank condition in the middle, which requires two commas.
2) Chart design
Merge a piece of cells under the dynamic column, insert a chart, the chart type is a column chart, the Data Source is Cell Data, the Category axis is A2, the Series is B2, and the Value is C2, as shown in the following figure:
3) Dynamic parameters
Insert a row at the top of the chart and below the dynamic column, enter the name of each data column (that is, the name of the data column that needs to be dynamically displayed), the entire report design is as shown below:
Select all the cells with data column names, namely cells A3 to C3, right-click, select the hyperlink, click the button, and add a Dynamic Parameters named col, as shown in the figure below:
Note: The meaning of the dynamic parameter is: when the hyperlink is clicked, the value of the currently clicked cell is passed to the parameter col, which is the parameter used in the dynamic column, so the cell where the dynamic column is located will be The value of the clicked data column is displayed, and the chart changes accordingly.
Hide the first and second rows where the dynamic column is located, and the template is complete.
3. Effect preview
Save the template and click pagination preview to view the effect shown above.
Note: If you want to display the category axis dynamically, you only need to set the category axis data source of the chart to a dynamically changing column in the dynamic column, ibid.
The completed template can refer to: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\ReportApplication\FeaturesApplication\Dynamic_display_chart_series.cpt