Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent column ordering in the exported CSV file when valueField is numeric #254

Open
emaillenin opened this issue Aug 27, 2020 · 0 comments

Comments

@emaillenin
Copy link

Non-numeric example: (using 'A1' as valueField)

https://codepen.io/emaillenin/pen/ZEWKWrL

CSV Output:

"Date","A1"
"Monday","2025"
"Tuesday","2125"
"Wednesday","2225"

Numeric example: (using '1' as valueField)

https://codepen.io/emaillenin/pen/dyMWMJK

CSV Output:

"1","Date"
"2025","Monday"
"2125","Tuesday"
"2225","Wednesday"

Expected: Column order should be same as what is provided in the dataProvider
Actual: Column order changes based on the key.

I looked at the source code for the export function. I think this is happening because Amcharts is building an object with each valueField:value as a key:value pair. Ordering is done in this order:

  1. integers in numeric order
  2. strings in chronological order
  3. Symbols in chronological order

https://www.stefanjudis.com/today-i-learned/property-order-is-predictable-in-javascript-objects-since-es2015/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant