[英]Error: Invalid value for <circle> attribute cx=“NaN” in dimple.js
I'm making a chart that can be updated with different data when a button is clicked. 我正在制作一个图表,单击按钮时可以用不同的数据更新图表。
The code below seems to works when the x-axis does not change its length, but when the x-axis length is changed and the chart updated I get this error: Error: Invalid value for <circle> attribute cx="NaN"
当x轴的长度不变时,下面的代码似乎起作用,但是当x轴的长度改变并且图表更新时,我收到此错误: Error: Invalid value for <circle> attribute cx="NaN"
Code: 码:
var svg = dimple.newSvg("#stepContainer", 400, 300);
var step_data = [
{Period: 1, FIP: (Math.random() * 1000000)},
{Period: 2, FIP: (Math.random() * 1000000)},
{Period: 3, FIP: (Math.random() * 1000000)},
{Period: 4, FIP: (Math.random() * 1000000)},
];
var stepChart = new dimple.chart(svg, step_data);
stepChart.setBounds(50, 40, 305, 205);
var myAxis = stepChart.addCategoryAxis("x", "Period");
stepChart.addMeasureAxis("y", "FIP");
var s = stepChart.addSeries(null, dimple.plot.line);
s.interpolation = "step";
stepChart.draw();
d3.select("#btn").on("click", function() {
// If the length of the x-axis stays the same I don't get the error
//var periods = 4;
var periods = Math.random()* 50;
arr = [];
for (i=1; i <=periods; i++) {
arr.push({Period: i, FIP: (Math.random() * 1000000)});
}
stepChart.data = arr;
stepChart.draw(1000);
});
What's causing this error? 是什么导致此错误?
fiddle: http://jsfiddle.net/jdash99/4pgd900f/9/ 小提琴: http : //jsfiddle.net/jdash99/4pgd900f/9/
This is an outstanding bug. 这是一个突出的错误。 It doesn't seem to affect display, it just raises an unwanted console error: 它似乎并没有影响显示,只是引发了不必要的控制台错误:
https://github.com/PMSI-AlignAlytics/dimple/issues/93 https://github.com/PMSI-AlignAlytics/dimple/issues/93
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.