Chart Object API

  • Last update:April 29, 2025
  • Version 

    Version
    Functional Change

    11.0.3

    Added the getCurrentChartIndex() API, which can be used to retrieve the chartIndex value of the chart that is currently being displayed.

    11.0

    /

     Chart.WebUtils.getChart


    API

    Chart.WebUtils.getChart(chartID)

    To obtain the chart block object.
    Parameter

    chartID

    A string that represents the unique identifier (ID) of the chart block containing the chart. In JavaScript, case sensitivity must be observed, and the parameter value must match the actual component name exactly.

    Example

    Example 1: You can obtain the chart inserted in a cell. The chartID represents the address of the cell containing the chart, for example, A1.

    FR.Chart.WebUtils.getChart("A1");

    Example 2: You can obtain the floating chart. The chartID represents the name of the floating element. You can select and right-click the floating element, and select Set Floating Element Name to view or modify the name of the floating element.

    FR.Chart.WebUtils.getChart("Float1");

    Example 3: You can obtain the chart block of an FRM report. The chartID represents the component name.

    FR.Chart.WebUtils.getChart("chart0");

    Example 4: You can obtain the chart inserted in a cell in the report block of an FRM report.

    FR.Chart.WebUtils.getChart("A1","report0");
    Mobile Terminal

    This API is supported on mobile terminals.

    Notes

    1. This API is not supported in extended charts.

    2. The implementation of all the above object retrieval methods differs between mobile terminals and PC. On mobile terminals, only a subset of these methods can be called via JavaScript.

    3. For charts in a report block of an FRM report, partial JavaScript calls are supported in DataAnalyst V11.0.63 and later versions.

    getChartWithIndex


    API

    getChartWithIndex(chartIndex)

    To obtain the chart object.

    Parameter

    chartIndex

    1. The value of the chartIndex parameter must be a number.

    2. By default, only one chart exists in a chart block, and the value of chartIndex is 0.

    3. When multiple charts exist within one chart block and Chart Switchover Attribute is configured, a specific value of chartIndex must be passed to obtain the corresponding chart. Therefore, to obtain the n-th chart, you should pass n-1 as the value of chartIndex.

    Example

    You can obtain the third chart object when three charts are configured with chart switchover.

    FR.Chart.WebUtils.getChart("A1").getChartWithIndex(2);
    Mobile Terminal

    This API is supported on mobile terminals.

    getCurrentChartIndex()


    API

    getCurrentChartIndex()

    To obtain the chartIndex value of the current table.

    When carousel is enabled as the chart switchover method, you are not advised to use getChartWithIndex() to retrieve chartIndex, as it may fail to obtain the correct chart object. In such cases, you need to use getCurrentChartIndex() instead.

    Parameter

    /

    /

    Example
    // Click the chart block to open the chart in full screen.
    (.vanchart-cc is used as an example. You should determine which element to bind the click event to based on the actual scenario.)
    $(".vanchart-cc").click(function({
            var chart = FR.Chart.WebUtils.getChart("chart0");
            var currentChartIndex = chart.getCurrentChartIndex(); 
    // Obtain chartIndex value of the current chart.        
            VanCharts.showLightBox(chart.getChartWithIndex(currentChartIndex));
    });
    Mobile Terminal

    This API is not supported on mobile terminals.

    series


    API

    series[seriesIndex]

    To obtain the series object.

    iconNote:
    This API must be used after you have obtained the chart object.
    Parameter

    seriesIndex

    By default, the chart object includes a series property, which stores an array of objects containing information about the chart's data series. To obtain a specific series object from the chart, you need to specify the corresponding index using seriesIndex, which starts from 0.

    Example

    Example 1: For pie charts, a series object corresponds to a pie chart. You can obtain all the data points in the slices of the first pie chart.

    chart.series[0].points;

    Example 2: If you have already obtained a chart object named PieChart, you can obtain the first series object in the chart using PieChart.series[0] and print the result in the browser.

    var PieChart=FR.Chart.WebUtils.getChart("A1").getChartWithIndex(2);console.log(PieChart.series[0]);
    Mobile Terminal

    Partial JavaScript calls are supported on mobile terminals.

    series.points


    API

    series.points[pointIndex]

    To obtain the data point object.

    iconNote:
    This API must be used after you have obtained the chart object.
    Parameter

    pointIndex

    Each series object contains a points property, which is also an array of objects. The points array stores the data point objects that you need.

    To obtain a specific data point object, you need to specify the corresponding index using pointIndex, which starts from 0.

    Example

    You can obtain all data points from the first series using chart.series[0].points. How can you obtain all data points from all series in the chart? You can use a simple loop as follows.

    var PieChart=FR.Chart.WebUtils.getChart("A1").getChartWithIndex(2);
    var points = [];
    PieChart.series.forEach(function (ser){
        points = points.concat(ser.points);
    })
    console.log(points);
    Mobile Terminal

    This API is not supported on mobile terminals.

    Property in Data Point Object

    In certain scenarios, you may only need a specific subset of data points that meet certain conditions. You can use Array.filter to specify the filter condition to obtain the required data point set accordingly. The following is an introduction to some common properties of data point objects, which can be used when you write filter conditions.

    PropertyDefinition

    point.name

    Name of the data point

    point.seriesName

    Name of the series that the data point belongs to

    point.category

    Name of the category that the data point belongs to

    point.value

    Value of the data point

    point.isVisible

    To determine whether the data point is visible.

    chart.showTooltip(point)

    To trigger a tooltip for the data point.

    For example, you can filter data points to obtain those with a value greater than 0.1. The code is as follows:

    var PieChart=FR.Chart.WebUtils.getChart("A1").getChartWithIndex(2);
    var points = [];
    PieChart.series.forEach(function (ser){
        points = points.concat(ser.points);
    })
    points = points.filter(function (p)return p.value > 0.1; })

    Attachment List


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

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

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

    不再提示

    7s后關閉

    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