【问题标题】:Can't load external data through D3无法通过 D3 加载外部数据
【发布时间】:2016-02-13 17:52:46
【问题描述】:
<script src="http://d3js.org/d3.v3.min.js"> </script>



<body>
<script>

    d3.text("data/cities.csv", function(text) {
        input = d3.csv.parseRows(text).map(function(row) {
            return row.map(function(value) {
                return +value;
            });
        });

    });



</script>
</body>

以下是我正在处理的数据

country,city,population,x,y,eu
Austria,Vienna,1826030,386,296,true
Belgium,Brussels,166497,251,240,true
Bulgaria,Sofia,1316557,482,385,true
Croatia,Zagreb,795505,382,337,true
Cyprus,Nicosia,200452,649,499,true

【问题讨论】:

  • 看来问题是你没有对input做任何事情。

标签: javascript d3.js


【解决方案1】:

除了获取 csv 之外,不确定您还想做什么。

正确的做法是:

d3.csv('data/cities.csv')
    .row(function(d) { return /* type the data here */ })
    .get(function(error, rows) { console.log(rows); });

请参阅https://github.com/mbostock/d3/wiki/CSV 以获得更多帮助。

【讨论】:

    猜你喜欢
    • 2011-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-03
    • 2012-09-13
    • 2013-10-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多