Closed arianagiorgi closed 6 years ago
I duplicated this behavior on ours. This should respect the given order.
Looks like sort order in API is incorrect at chartwerk.datamap.sort
, which is set here.
Looking at the csvtojson library that gives the order, one person had the same issue, which was fixed by turning off the type sniffing in checkType param. That is now false by default in current versions, so it may just need a version bump in this repo.
If that doesn't fix it, then I may need to set the header order from the raw data string before converting to JSON, which I'll need to test against some other conditions...
Adding as bug for quick fix. (hi, ariana!)
So on closer look, EMCA guarantees that keys that are integer-like will always come before alpha keys in JS objects (though alpha keys can be arbitrarily sorted).
So to sort data properties, chart templates should use the sort order in chartwerk.datamap.sort
, which will be an array of the headers as sorted in the original data.
@arianagiorgi you may just need to adjust the data table chart template a little to get what you need now.
The datatable sorts the columns by ordering the columns with numbers as headers first.