How to attach properties other than x,y,y0 to a layer of streamgraph in d3?

我的未来我决定 提交于 2019-12-05 15:46:03

Use stack.values, and then wrap each layer's data points with some additional data for the layer. Your data will look something like this:

[
  {
    "type": "apples",
    "values": [
      { "x": 0, "y":  91},
      { "x": 1, "y": 290}
    ]
  },
  {  
    "type": "oranges",
    "values": [
      { "x": 0, "y":  9},
      { "x": 1, "y": 49}
    ]
  }
]

And the stack layout like this:

var stack = d3.layout.stack()
    .offset("wiggle")
    .values(function(d) { return d.values; });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!