gpt4 book ai didi

javascript - 错误: Invalid value for attribute cx ="NaN" in dimple.js

转载 作者:行者123 更新时间:2023-11-28 08:02:23 25 4
gpt4 key购买 nike

我正在制作一个图表,单击按钮时可以使用不同的数据进行更新。

当 x 轴不改变其长度时,下面的代码似乎有效,但是当 x 轴长度改变并且图表更新时,我收到此错误:Error: Invalid value for <circle> attribute cx="NaN"

代码:

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);
});

什么原因导致此错误?

fiddle :http://jsfiddle.net/jdash99/4pgd900f/9/

最佳答案

这是一个突出的错误。它似乎不会影响显示,它只会引发一个不需要的控制台错误:

https://github.com/PMSI-AlignAlytics/dimple/issues/93

关于javascript - 错误: Invalid value for <circle> attribute cx ="NaN" in dimple.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25235183/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com