Hi Brian,
You're right, there is something fishy going on here..
When the sort attribute is a number (e.g. 1, 2 , 3) , it won't sort as expected.
When the sort attribute is a string (e.g. ‘point 1’, ‘point 2’, ‘point 3’), it sorts exactly as expected: alphabetically asc/desc.
Weird thing though, if the sort attribute is a string and you set it to ‘1', ‘2', '3’, the sorting is broken again.
Conclusion: Chart widget can spell but not count :)
I'd say this is a bug in the widget (or fluke in the documentation) and you could file an issue for it on Github.
In the mean time, move to a different charting widget..
Regards,
Jeroen
Edit:
According to Plotly docs, it's default behaviour (no bug in the widget).
Plotly will try to infer the data type, but you can force it to use something else.
Adding: { "xaxis": { "type": "category" }} as Advanced configuration (Chart level not series) seems to work, it's even possible to use the integer sort attribute and still sort correctly.
I’ve tried everything. Sorting descending by an autonumber field. Changing the data type of the field i’m trying to sort on. Changing the sort field to an associated field, selecting a MICROFLOW as the data source and manually adding records to a list, setting the sort on that list via an activity and returning the last and THEN selecting both ascending AND descending on that list. Literally.. Nothing.
Basically, Mendix chart sorting is completely broken. It will always been ascending. Maybe they should considering taking out the sort option so people don’t count on certain features which aren’t available.
Brian,
I don't have experience with the basic widget in regards of sorting, but maybe you can try the ploty configuration to apply the sort action you are looking for:
In the widget, In the advanced tab of the series item, add this json snippet:
"transforms": [
{
"type": "sort",
"target": "x",
"order": "descending"
}
]
let me know if that works.
GL, Ruud
I have a different solution, hopefully it helps those who still struggle with this. In the plotly docs, I found this which worked for me:
Link to docs: https://plotly.com/python/categorical-axes/
Search for 'category ascending' and you'll find it.