javascript d3.js t.map 不是函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17088916/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
d3.js t.map is not a function
提问by mirba
Hope somebody can help me out because I can't find any reference about this error.
希望有人可以帮助我,因为我找不到有关此错误的任何参考。
I was working on this piece of code:
我正在处理这段代码:
var xMin = d3.min(data, function(d) { return d.value; });
var xMax = d3.max(data, function(d) { return d.value; });
if (0 > xMin & 0 > xMax) {
xMax = 0;
}
if (0 < xMin & 0 < xMax) {
xMin = 0;
}
x.domain(xMin, xMax).nice();
y.domain(data.map(function(d) { return d.label; }));
but I must have made some mistake cause now the loading blocks with the error message below in the web console:
但我一定犯了一些错误,因为现在加载块在 Web 控制台中显示以下错误消息:
"TypeError: t.map is not a function @ http://d3js.org/d3.v3.min.js:2
“类型错误:t.map 不是函数 @ http://d3js.org/d3.v3.min.js:2
回答by Lars Kotthoff
.domain()
takes an array as argument, i.e.
.domain()
以数组作为参数,即
x.domain(xMin, xMax).nice();
should be
应该
x.domain([xMin, xMax]).nice();