If predefined sort order is available, X-axis or chart legend can be sorted by using this script. But in some cases we may not know the sort order in advance and sorting has to be done based on a rank field in the table. Also maintenance will be easy if we sort the chart by rank field instead of widget script. This can be achieved using a script.
In order to do it, we need a rank column. For example, If we need to sort Region based on a field, we need Region and rank column (say, Region Rank)
Create line/bar/column chart
Add the script to widget and update the variables:
Save script and refresh the widget.
Contact us for the script - email@example.com