【问题标题】:Error when creating features in d3.js cartogram在 d3.js 地图中创建要素时出错
【发布时间】:2015-09-29 01:18:57
【问题描述】:

我正在使用 d3.js 制作一个简单的制图,但在绘制原始地图时遇到了错误。 我用here 的例子写了一个要点。 我得到的错误是当我尝试创建这样的功能时:

geometries = topology.objects.mex_estados.geometries;
var features = carto.features(topology, geometries)

topology 是 d3.json 调用返回的对象,我得到的错误是“Uncaught TypeError: topojson.object is not a function”,由对 carto.features 的调用触发。

变量carto的定义方式通常是:

var proj =  d3.geo.mercator()
.center([-97.16, 21.411])
.scale(1000);

var carto = d3.cartogram()
  .projection(proj)
  .properties(function (d) {
    //regresa también las propiedades (valores) de la fuente de dato
    return d.properties;
});

我被困在这里,我以前用 d3 制作过地图,但我必须在这里遗漏一些明显的东西,感谢任何帮助

【问题讨论】:

    标签: javascript d3.js cartogram


    【解决方案1】:

    原来我使用了错误版本的 Cartogram.js,而不是使用托管在 http://prag.ma/code/d3-cartogram/cartogram.js 的版本,而是使用托管在 GitHub 的库版本更新了要点,一切正常!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-09
      • 1970-01-01
      • 2017-05-05
      • 2021-04-06
      • 2014-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多