Methods of getting chart object

  • Last update:  2021-06-07
  • I. Get chart block object

    1. Usage

    The chart block object chartWidget can be obtained through FR.Chart.WebUtils.getChart(chartID).

    Note: chartID is a string type, which represents the unique identification ID of the chart block where the current chart is located.

    MethodType Description
    FR.Chart.WebUtils.getChart("chartID")CellchartID is the cell name, such as: A1
    FR.Chart.WebUtils.getChart("chartID")Floating elementchartID is the name of the floating element, select the floating element, right click to view or set the name of the floating element
    FR.Chart.WebUtils.getChart("chartID")DashboardThe chart widget added in the dashboard, chartID is the widget name
    FR.Chart.WebUtils.getChart("chartId","reportName")DashboardWhen there are multiple report blocks in the dashboard, get the chart in the report block

    Note: The mobile terminal supports some JS to call this method.


    2. Example

    The way to get the chart block object in cell A1 is as follows:

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

    3. Note

    • This interface does not support extended charts.

    • The implementation of all the above methods of obtaining objects on the mobile terminal is different from that on PC. The mobile terminal only supports some JS to call these methods.

    • The chart in the report block of the mobile dashboard does not support calling all the above methods.

    II. Get chart object

    1. Usage

    After obtaining the chart block object chartWidget, you can use chartWidget.getChartWithIndex(chartIndex) to obtain the chart object. By default, there is only one chart in the chart block, and the chartIndex is 0 at this time.

    Note: chartIndex is a number.

    When the chart switch is set, that is, when there are multiple charts in a chart block, the specific chartIndex needs to be passed in to obtain the specific chart object.

    chartIndex starts counting from 0, which means that if you want to get the nth chart, then the incoming chartIndex should be n-1.

    Method
    FR.Chart.WebUtils.getChart(chartID).getChartWithIndex(chartIndex)

    Note: The mobile terminal supports some JS to call this method.


    2. Example

    There are 3 charts set up for chart switching, and the way to get the third chart object is as follows:

    FR.Chart.WebUtils.getChart("A1").getChartWithIndex(2)

    III. Get series object

    1. Usage

    The default chart object has a series attribute, which stores data information related to the series in the chart, which is an array of objects.

    If you want to get a specific series object in the chart, you need to specify the corresponding index, which starts counting from 0.

    Method
    chart.series[seriesIndex]

    Note: The mobile terminal supports some JS to call this method.


    2. Example

    Assuming that you have obtained the chart object PieChart, and now you want to obtain the first series object in it, you can use PieChart.series[0] to get it.

    You can print in the browser:

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

    IV. Get data point object

    1. Usage

    Each series object also has a points attribute, which is also an object array. This points array stores the data point object we want.

    If you need to get a specific data point object, you need to specify the index of the data point, and pointIndex starts counting from 0.

    Method
    series.points[pointIndex]

    2. Example

    chart.series[0].points, you can get the collection of all data points under the first series. So what if you want to get the collection of all the data points under the chart? Only need a simple traversal operation to complete:

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

    V. Attributes in the data point object

    1. Usage

    In some scenarios, all you need is a collection of data points that meet a certain condition. At this time, you can specify the filter conditions through Array.filter to filter out the desired data point collection.

    Here is an introduction to some attributes in the data point object. You need to use it when writing filter conditions:

    Attribute   Meaning
    point.nameThe name of the data point
    point.seriesNameThe name of the series corresponding to the data point
    point.categoryThe category name corresponding to the data point
    point.valueThe value of the data point

    2. Example

    Filter the collection of data points with a value greater than 0.1, written 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
    • 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