错误:属性d= " MNaN,NaNA5,5 0 1,1 NaN,NaNL0,0Z "的无效值。

时间:2020-12-19 18:46:35

I try to make pie chart with dimple library it works for all chart type like line, bubble and bar but when i try with pie chart I get the following error

我试着做一个饼图,它适用于所有的图表类型,比如线,气泡和酒吧,但是当我尝试做饼图时,我得到了下面的错误。

    Error: Invalid value for <path> attribute d="MNaN,NaNA5,5 0 1,1 NaN,NaNL0,0Z" 

This is the code

这是代码

   <script type="text/javascript">
      var svg = dimple.newSvg("#chartContainer", 590, 400);
           var array1=[10,20,30,40,50];
           var array2=[600,300,400,200,100];
           var data = new Array();
                  for (var i = 0; i < array1.length; ++i) {
                      data.push({ x : array2[i], y: array1[i]});
                }
           var myChart = new dimple.chart(svg, data);
               myChart.setBounds(60, 30, 510, 305)
               var x = myChart.addCategoryAxis("x", "x");
               myChart.addMeasureAxis("y", "y");
               myChart.addSeries(null, dimple.plot.pie);
               myChart.draw();
     </script>

Can anyone help me please?

有人能帮我吗?

1 个解决方案

#1


0  

Dimple's documentation on pie charts isn't very good. From what I can puzzle out from there examples, pie charts are treated somewhat differently.

Dimple在饼图上的文档不是很好。从我所能理解的例子中,饼图的处理方式有所不同。

  1. The require a measured axis of position "p".
  2. 要求测量的位置轴为p。
  3. They require a categoryField when adding the series.
  4. 在添加这个系列时,它们需要一个categoryField。

So fixing your example code, it becomes:

因此,修改示例代码,它就变成:

var svg = dimple.newSvg("#chartContainer", 590, 400);
var array1 = [10, 20, 30, 40, 50];
var array2 = [600, 300, 400, 200, 100];
var data = new Array();
for (var i = 0; i < array1.length; ++i) {
  data.push({
    x: array2[i],
    y: array1[i]
  });
}
var myChart = new dimple.chart(svg, data);
myChart.setBounds(60, 30, 510, 305)
//var x = myChart.addCategoryAxis("x", "x");
//myChart.addMeasureAxis("y", "y");
myChart.addMeasureAxis("p", "x");
myChart.addSeries("y", dimple.plot.pie);
myChart.draw();

Example here.

例子。

#1


0  

Dimple's documentation on pie charts isn't very good. From what I can puzzle out from there examples, pie charts are treated somewhat differently.

Dimple在饼图上的文档不是很好。从我所能理解的例子中,饼图的处理方式有所不同。

  1. The require a measured axis of position "p".
  2. 要求测量的位置轴为p。
  3. They require a categoryField when adding the series.
  4. 在添加这个系列时,它们需要一个categoryField。

So fixing your example code, it becomes:

因此,修改示例代码,它就变成:

var svg = dimple.newSvg("#chartContainer", 590, 400);
var array1 = [10, 20, 30, 40, 50];
var array2 = [600, 300, 400, 200, 100];
var data = new Array();
for (var i = 0; i < array1.length; ++i) {
  data.push({
    x: array2[i],
    y: array1[i]
  });
}
var myChart = new dimple.chart(svg, data);
myChart.setBounds(60, 30, 510, 305)
//var x = myChart.addCategoryAxis("x", "x");
//myChart.addMeasureAxis("y", "y");
myChart.addMeasureAxis("p", "x");
myChart.addSeries("y", dimple.plot.pie);
myChart.draw();

Example here.

例子。