I am trying to add a button that will allow a user to sort a stacked bar chart that has been loaded via CSV.
I have seen other solutions that involve writing sort functions and parsing the data. However, there is an existing sort value that I can set, so I think I should be able to change that value and redraw the chart.
Here is a Fiddle of my chart: https://jsfiddle.net/v41x92c6/23/
By changing the initial value on line 1 of the JS, you can set the default sort to the name or value. Either will work.
If "value" the bars are sorted by the value in the first category of the stacked bar chart "focused". This is exactly what I want the default sort to be.
If "name", the bars are sorted alphabetically, with A at the bottom. By changing the value of the variable and rerunning, you can see the change that I want to trigger via a button.
I have three buttons showing different attempts to resort the graph.
The first 2, get the current sort value from the chart and attempt change it.
The 3rd gets the current sort value from the initially set global variable on line 1 and changes it.
None work, but I thought I'd include them all to show some of the directions I've tried.