Overview
Version
Report Server Version |
---|
11.0 |
Expected Effect
When creating charts, you may want the prompt content to obtain dataset data and display the data with upright or inverted triangle icons indicating the increase or decrease respectively, as shown in the following figure.
Implementation Method
If you just want to display dataset fields, you can add the fields through Rich Text for some types of charts. Since you cannot customize the content style by formulas or codes in Rich Text Editor, you can only use custom codes to customize the content style under Prompt > Content > Custom. Use the formula in the code to obtain fields from the dataset and customize the style of triangle icons, as shown in the following figure.
Example
Data Preparation
Choose File > New General Report in the upper left corner of the designer and select Refresh Technology as the template theme.
Create a built-in dataset, modify the name to ds1, and design the table as shown in the following figure.

Report Design
Chart Insertion
Select required cells, click the Merge Cells icon on the upper toolbar, click the Insert Chart icon, select Column Chart, and click OK, as shown in the following figure.
Data Binding
Select the chart, choose Cell Element > Data on the right property panel, bind the data from the dataset to the chart, and set Category to Range, Series Name to Field Name, and Field Name to Today, as shown in the following figure.
Chart Style Setting
1. Title Setting
Select the chart, choose Cell Element > Style > Title, enter Custom Tooltip Content, and set Position to left, as shown in the following figure.
2. Legend Setting
Since the chart has only one series, you can deselect Show Legend.
3. Prompt Setting
Select the chart, choose Cell Element > Style > Prompt, select Custom for Content, and enter the following code:
function() {
var per=(FR.remoteEvaluate("value('ds1',3,1,'"+this.category+"')")*100).toFixed(0);
//Get the data in the third column from the dataset ds1. The corresponding value in the first column corresponding to the third column is this.category
return "Range: "+this.category+"<br>Customer Quantity: "+this.value+"    Compared to Yesterday "+
(per<0?"<font color='#ea4431'>▼</font> ":"<font color='#16c153'>▲</font> ")+Math.abs(per)+"%";
//If the value of per is less than 0, a red inverted triangle icon is displayed. If the value of per is greater than 0, a green upright triangle icon is displayed. The absolute value of per is taken.
}
After entering the code, you need to select Use HTML to Parse Text Content, as shown in the following figure.
Restriction on Calling Formulas by Scripts
Restrictions apply in the call by the FR.remoteEvaluate script in the code. You need to choose Server > Platform Management on the designer menu bar to enter the decision-making system. Choose System Management > Security Management> Security, and disable Forbide Script to Call Formula, as shown in the following figure.
If Forbide Script to Call Formula is enabled, incorrect data will be displayed during the template preview, and a prompt will pop up on the right side, as shown in the following figure.
Effect Display
PC
Save the report and click Pagination Preview. The effect is the same as in section "Expected Effect."
Mobile Terminal
The template can be previewed on both the DataAnalyst app and the HTML5 terminal. The following figure shows the effect.
Template Download
For details, you can download the example template: Custom Field Content for Tooltips.cpt.