【问题标题】:d3.js Faux-3D Arcs - Uncaught typeerror: Cannot read property 'objects' of undefinedd3.js Faux-3D Arcs - 未捕获的类型错误:无法读取未定义的属性“对象”
【发布时间】:2015-05-23 09:24:56
【问题描述】:

数据
世界 110m.json
地方.json

代码

queue()
    .defer(d3.json, "http://bl.ocks.org/dwtkns/raw/4686432/world-110m.json")
    .defer(d3.json, "https://raw.githubusercontent.com/fraserxu/d3-map/master/datas/places.json")
    .await(ready);

来源
[http://bl.ocks.org/dwtkns/4973620]

错误

未捕获的类型错误:无法读取未定义的属性“对象”

在下面的代码中:

 svg.append("path")
    .datum(topojson.object(world, world.objects.land))
    .attr("class", "land noclicks")
    .attr("d", path);

我已将 index.html 部署到 IIS 中,并尝试将 json 数据文件放在同一位置,并尝试使用以下内容:

queue()
    .defer(d3.json, "world-110m.json")
    .defer(d3.json, "places.json")
    .await(ready);

任何关于如何克服这个问题的建议都会有真正的帮助。
谢谢,

【问题讨论】:

  • 我的系统需要安装 TopoJson 吗?
  • 你链接的例子对我有用,有什么问题?

标签: javascript json d3.js queue topojson


【解决方案1】:

我找到了解决方案。我收到了这 2 条错误消息:

d3.v3.min.js:1 GET http://localhost/d/4686432/world-110m.json 404 (Not Found)

main.php:139 Uncaught TypeError: Cannot read property 'objects' of undefined
at ready (main.php:139)
at y (queue.v1.min.js:1)
at i (queue.v1.min.js:1)
at Object.<anonymous> (queue.v1.min.js:1)
at Object.t (d3.v3.min.js:1)
at XMLHttpRequest.i (d3.v3.min.js:1)

这导致呈现一个空的地球:

Empty Globe

我在网上搜索了“world-110m.json”,找到了这个文件:

world-110m.json

在我的项目目录中,我创建了一个目录“d”,并在其中创建了一个名为“4686432”的目录。我在“4686432”中创建了一个文件“world-110.json”,并将上一个链接中的代码复制到该文件中。

地球现在可以正确渲染:

Correctly rendered globe

【讨论】:

    猜你喜欢
    • 2016-06-04
    • 2014-04-13
    • 1970-01-01
    • 1970-01-01
    • 2016-08-24
    • 1970-01-01
    • 1970-01-01
    • 2012-11-22
    • 1970-01-01
    相关资源
    最近更新 更多