Chart data tooltip auto display

  • Last update:December 14, 2020
  • I. Overview

    1.1 Problem

    Sometimes we may want to auto display the chart data tooltip, like the effect below:

    chart-carousel.gif


    1.2 Solution

    Obtain the chart object that needs to be operated first, and then call the openTooltip method of this chart object to enable the auto play of data tooltip.

    chart.openAutoTooltip([delay, initPoints]);
    Parameter
    Description
    delay

    Tooltip switching time interval, the default is 3s

    initPoints

    The data points to be auto displayed, the default is all data points in the chart

    After calling this method, it will return a controller for turning off the auto display. Through the controller.stop() method, you can stop the automatic tooltip display, as shown in the following table: 

    JS
    Description

    var controller = chart.openAutoTooltip()   

    Turn on automatic data point tooltip display

    controller.stop()

    Stop automatic data point tooltip display

    controller.moveOn()

    Continue automatic data point tooltip display from where it is stopped

    II. Example

    2.1 General report

    2.1.1 Turn on automatic tooltip display

    After adding the chart, add a hyperlink->JavaScript to cell A1 text, and add the following code; Get the chart block object FR.Chart.WebUtils.getChart("chartID"). The chartID is the cell number of the current chart, such as "A3" in the code. 

    image.png

    //Get chart object
    var vanchart =FR.Chart.WebUtils.getChart("A3").getChartWithIndex(0);
    //Turn on auto display tooltip
    vanchart.controller = vanchart.openAutoTooltip();

    If you want to display only the values greater than 12000, the reference code is as follows:

    var vanchart =FR.Chart.WebUtils.getChart("A3").getChartWithIndex(0);//Get chart object
    var points = []; 
    vanchart.series.forEach(function (ser){//Get all data point
        points = points.concat(ser.points);
    }) 
    points = points.filter(function (p){//Filter data point higher than 12000
        return p.value > 12000;
    })
    var delay=1000//Switching interval is 1 second
    vanchart.openAutoTooltip(delay,points);//Turn on auto display

     

    2.1.2 Stop automatic tooltip display

    Add a js hyperlink to the text in C1:

    image (1).png

    //Get chart object
    var vanchart =FR.Chart.WebUtils.getChart("A3").getChartWithIndex(0);
    //Stop automatic tooltip display
    vanchart.controller.stop();


    2.1.3 Stop automatic tooltip display

    Add a js hyperlink to the text in E1:

    image (2).png

    //Get chart object
    var vanchart =FR.Chart.WebUtils.getChart("A3").getChartWithIndex(0);
    //Continue automatic tooltip display from where it is stopped
    vanchart.controller.moveOn();

     

    2.2 dashboard

    For the chart in dashboard, add an after initialization event to the chart component.

    image (3).png

    setTimeout(function(){
    var vanchart =FR.Chart.WebUtils.getChart("chart0").getChartWithIndex(0);
    vanchart.openAutoTooltip();
    },1000)

    Or you can also use button to add a click event to achieve the same effect.

    var vanchart =FR.Chart.WebUtils.getChart("chart0").getChartWithIndex(0);
    vanchart.openAutoTooltip();


    III. Download template

    3.1 General report

    js-PointCarousel.cpt


    3.2 Dashboard

    js-PointCarousel.frm


    Attachment List


    Theme: Secondary Development
    • Helpful
    • Not helpful
    • Only read

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

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

    不再提示

    10s後關閉

    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