holtzy / D3-graph-gallery

A collection of simple graphics made with D3.js
https://www.d3-graph-gallery.com
MIT License
791 stars 237 forks source link

Order bars in stacked circular barplot #7

Closed melwazir closed 3 years ago

melwazir commented 4 years ago

Hi! Love the website and thanks for the amazing charts. I just used the stacked grouped circular barplot (https://www.r-graph-gallery.com/299-circular-stacked-barplot.html), and needed to order the bars like you did in the regular one (https://www.r-graph-gallery.com/297-circular-barplot-with-groups.html), so after some tinkering I got it to work by replacing this line: data <- data %>% arrange(group, individual)

with this line:

data <-data %>% group_by(group, individual) %>% mutate(sumValue=sum(value, na.rm = T)) %>% arrange(group, sumValue, individual) %>% ungroup()

Just thought I'd share back if you'd like to add it as an optional feature.

Thanks again for your work!

holtzy commented 3 years ago

This repo is about the D3 graph gallery! :) but thanks