【问题标题】:Error: Invalid value for <circle> attribute cx="NaN" in dimple.js错误:dimple.js 中 <circle> 属性 cx="NaN" 的值无效
【发布时间】:2014-10-03 19:17:21
【问题描述】:

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

当 x 轴不改变其长度时,下面的代码似乎可以工作,但是当 x 轴长度改变并更新图表时,我收到此错误:Error: Invalid value for &lt;circle&gt; 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);
        });

是什么导致了这个错误?

小提琴:http://jsfiddle.net/jdash99/4pgd900f/9/

【问题讨论】:

    标签: javascript d3.js dimple.js


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2014-05-15
      • 2015-01-24
      • 2015-06-26
      • 2013-08-18
      • 2016-02-10
      • 2020-10-22
      • 2023-03-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多