(抱歉我的英语水平不好)嗨,我第一次使用 D3 和 mithril js。地图没问题,但我对省份的颜色有疑问,它来自“d”属性来获取省份的 id。该属性未定义,我不明白“d”到底是什么。是秘银的问题吗?还有其他方法可以获取“d”属性吗?
controller.map = function(el){
var width = 1160;
var height = 960;
var scale = 10000;
var offset = [width / 2, height / 2];
var center = [0, 50.64];
var rotate = [-4.668, 0];
var parallels = [51.74, 49.34];
var projection = d3.geo.albers()
.center(center)
.rotate(rotate)
.parallels(parallels)
.scale(scale)
.translate(offset)
;
var path = d3.geo.path()
.projection(projection)
;
var svg = d3.select(el).append("svg")
.attr("width",width)
.attr("height",height)
;
d3.json("belprov.json",function(error,be){
if (error) return console.error(error);
var bounds = path.bounds(topojson.feature(be, be.objects.subunits));
var hscale …Run Code Online (Sandbox Code Playgroud)