holtzy / D3-graph-gallery

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

tidy data stack keys #49

Open wallacemoraes opened 3 years ago

wallacemoraes commented 3 years ago

hello, Please, why didn't you use people's names? Where do these numbers come from? var mygroup = [1,2,3] How can I use the names instead of numbers? Thank you https://www.d3-graph-gallery.com/graph/stackedarea_basic.html // Stack the data: each group will be represented on top of each other var mygroups = ["Helen", "Amanda", "Ashley"] // list of group names var mygroup = [1,2,3] // list of group names var stackedData = d3.stack() .keys(mygroup) .value(function(d, key){ return d.values[key].n }) (sumstat)