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.
Method | Type | Description |
---|---|---|
FR.Chart.WebUtils.getChart("chartID") | Cell | chartID is the cell name, such as: A1 |
FR.Chart.WebUtils.getChart("chartID") | Floating element | chartID 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") | Dashboard | The chart widget added in the dashboard, chartID is the widget name |
FR.Chart.WebUtils.getChart("chartId","reportName") | Dashboard | When 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.name | The name of the data point |
point.seriesName | The name of the series corresponding to the data point |
point.category | The category name corresponding to the data point |
point.value | The 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; })