Loading D3.js data from a simple JSON string

后端 未结 6 796
礼貌的吻别
礼貌的吻别 2020-11-28 06:29

Most of the examples in gallery load data from TSV files.

How can I convert the following to use a local json variable instead of TSV data?

d3.tsv(&quo         


        
6条回答
  •  臣服心动
    2020-11-28 07:08

    Just change data to an array of objects like this:

    let data = [{"apples":53245,"oranges":200},{"apples":28479,"oranges":200},{"apples":19697,"oranges":200},{"apples":24037,"oranges":200},{"apples":40245,"oranges":200}]
    

    and comment out the d3.tsv("data.tsv", function(error, data) {...

提交回复
热议问题