Currently this stacked bar chart is sorted from left to right based on the total of each bar. How would I also sort each individual bar so that instead of sorting each individual bar by the key (i.e. Under 5 years old is at the bottom and 65 years and over is at the top) it would sort each individual bar by the value (largest at the bottom and smallest at the top).
For example:
Currently the CA bar is stacked like this (from bottom to top)
CA,2704659,4499890,2159981,3853788,10604510,8819342,4114496
I would like it stacked like this (from bottom to top)
CA,10604510,8819342,4499890,4114496,3853788,2704659,2159981
Just to be clear, I need to be able to do this on the client side (i.e. changing the order or format of the original data is not an option).
stack.order(), but this will affect the order for all bars. I don't think D3 allows you to sort each bar differently (unless you use separate stack layouts for each). - Lars Kotthoffstack.order()to achieve that I would greatly appreciate it. - diasks2d.agesas you want it (inside thedata.forEachloop). You could even do different orders for different bars! - Lars Kotthoff