使用d3.js绘制气泡图时,我收到一条奇怪的无名错误信息。图表正在运行,但错误未执行后代码。
Error: d3.v4.js:3554:42
easeConstant https://d3js.org/d3.v4.js:3554:42
transition_ease https://d3js.org/d3.v4.js:3564:19
drawbubble http://testinvest.pl4y6r0und.net/JSInclude/d3.bubblegraph.js:143:5
<anonym> http://testinvest.pl4y6r0und.net/KeywordCorrelation.php:84:21
fire https://code.jquery.com/jquery-1.12.4.js:3232:11
fireWith https://code.jquery.com/jquery-1.12.4.js:3362:7
done https://code.jquery.com/jquery-1.12.4.js:9840:5
callback https://code.jquery.com/jquery-1.12.4.js:10311:8
这就是drawbubble:143看起来像
svg.selectAll("circle")
.data(data)
.enter()
.insert("circle")
.attr("cx", width / 2)
.attr("cy", height / 2)
.attr("opacity", function (d) {
return opacity(d.size);
})
.attr("r", function (d) {
return scale(d.size);
})
.style("fill", function (d) {
return color(d.c);
})
.on('mouseover', function (d, i) {
fade(d.c, .1);
})
.on('mouseout', function (d, i) {
fadeOut();
})
.transition()
.delay(function (d, i) {
return x(d.x) - y(d.y);
})
.duration(500)
.attr("cx", function (d) {
return x(d.x);
})
.attr("cy", function (d) {
return y(d.y);
})
.ease("bounce");
答案 0 :(得分:2)
您对.ease("bounce")
的使用看起来像leftover from d3 v3,但我可以看到您正在使用v4(https://d3js.org/d3.v4.js
)。尝试更新代码,改为使用easeBounce
of v4。这是一个很好的参考:https://bl.ocks.org/d3noob/1ea51d03775b9650e8dfd03474e202fe