I. Overview
1.1 Problem
If the chart data is fetched through sql statement, it can be sorted directly in sql. But if you use other methods to get the data, and you want to sort the chart by numerical value, how to do that?
1.2 Solution
After obtaining the chart object to be sorted through vanchart.sortChart(sortType) , you can set the chart sorting method.
Note:
Parameter sortType defines the sort type, and is optional. Values are 1 or -1. Where it is 1 means ascending order, -1 means descending order.
If you do not write sortType parameters, the chart will be switched to the opposite sort sequence based on the current sequence.
This method does not support mobile terminals.
II. Example
2.1 Report design
Add a chart and bind the data source to it.
2.2 Add click event
Place a button above the chart and add a click event to it.
Add following JS; For example, sort in ascending order:
var chart = FR.Chart.WebUtils.getChart("chart0").vanCharts.charts[0]; //Get the first chart tab of the chart0 component, which is the default chart
chart.sortChart(1); //Set sorting type
2.3 Preview effect
Click save and preview. You can see that the chart series values are sorted in ascending order after clicking the button: