Basic chart sorting not working

I have a simple entity. Two fields.  COST: Decimal SORT: Integer Values are  COST: 3000, SORT: 1 COST:3500, SORT: 2 COST:3600, SORT: 3 I set up a column chart and set up a static series. The is set to database and uses this entity. Under data points I set the SORT as the x axis and COST as Y axis. I set the X axis sort attribute as SORT with descending order. The Chart however just shows in ascending order. I tried reversing it to ascending. Still ascending in the chart.  There are no associations. No dynamics series. No advanced layout options...Nothing at all beyond this basic setup and no MATTER what I try, the chart ALWAYS shows in ascending order when I want it descending. Can anyone think of why this might be? Is there something I’m missing? I can’t believe something broken down into the most simplified example I can think of, just doesn’t work.
4 answers

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..





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.



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:

Search for 'category ascending' and you'll find it.