D3 Stacked Chart with array or JSON data

后端 未结 3 2129
谎友^
谎友^ 2021-02-10 09:39

I want to create a Stacked bar chart like http://bl.ocks.org/mbostock/3886208 . But I don\'t want to use CSV file.

How can I create Stacked chart using array or JSON dat

3条回答
  •  悲&欢浪女
    2021-02-10 10:24

    If you have an array, data, you can use that just like the parameter data in the csv function in the example you linked. The code within that function will work as expected, provided that your data is in the same format.

    If you can set breakpoints with your browser, you can have a look at what that format is fairly easily, set one just inside the csv function call in the js and look at the data variable.

提交回复
热议问题