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.
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.
Example 3: You can obtain the chart block of an FRM report. The chartID represents the component name.
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 |
| |
Mobile Terminal | This API is not supported on mobile terminals. |
series
API | series[seriesIndex] | To obtain the series 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.
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. ![]() |
---|---|---|
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.
| |
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.
Property | Definition |
---|---|
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; })