Obtaining Dataset Data by the Prompt

  • Last update:March 09, 2025
  • 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.

    iconNote:
    In the Compared to Yesterday field, positive numbers indicate an increase, while negative numbers indicate a decrease.

    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+" &nbsp&nbsp Compared to Yesterday "+
    (per<0?"<font color='#ea4431'>▼</font>&nbsp":"<font color='#16c153'>▲</font>&nbsp")+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.
    }

    Note:
    FR.remoteEvaluate is used to invoke the VALUE function in FineReport to obtain values from the dataset.

    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.


    Attachment List


    Theme: Chart
    Already the First
    Already the Last
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    9s后關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy