如何使用JSON格式而不是CSV工作D3



我试图将我的数据从JSON到D3 Visual的群体。我有一个json结果,使我的约会和计数。

如何用JSON替换此功能?原始链接从这里获得了我的D3样本

 d3.csv('@Server.MapPath("Views/file/sp500.csv")', type, function (error, data) {

JSON文件

[{Month: "February 2014", Count: 50}, {Month: "March 2014", Count: 66},…]

目前确实发射了JSON,但有一个错误说cannot read the property of null

d3.json("/JuraServicing/GetStatistic", function (data) {

您只需要在JSON文件中具有双重引用的钥匙值即可。那应该很好。

这很好:

<!DOCTYPE html>
<html>
<head>
    <script src="https://d3js.org/d3.v4.min.js"></script>
</head>
<body>
    <script>
        d3.json("/data.json", function (data) {
                document.write(JSON.stringify(data))
        });
    </script>
</body>
</html>

这是data.json

[{"Month": "February 2014", "Count": 50}, {"Month": "March 2014", "Count": 6}]

希望它有帮助!

最新更新