错误:<g>属性转换:预期数字,“translate(NaN,0)”

时间:2018-05-16 15:47:44

标签: html d3.js c3.js

显示以下图表时(仍然有效)。我收到以下错误:

Error: <g> attribute transform: Expected number, "translate(NaN, 0)".

我的代码如下:

var Attempts = c3.generate({
  bindto: '#attempts',
  data: {
      url: 'attempts.csv',
      x:"index",
      type: 'donut',
      onclick: function (d, i) { console.log("onclick", d, i); },
      onmouseover: function (d, i) { console.log("onmouseover", d, i); },
      onmouseout: function (d, i) { console.log("onmouseout", d, i); }
  },
  donut: {
    label: {
      format: function (value) { return value; }
    }
  }
});

attempts.csv是:

index,Basic Mechanics,Basic Thermodynamics,Calculus I,Calculus II,Chemistry I,Chemistry II,Engineering Drawing,Fundamentals of Informatics,Geometry,Linear Algebra
ATTEMPTS,1.416,1.404,1.421,1.347,1.305,1.246,1.261,1.456,1.325,1.385

完整错误是:

c3_chart_internal_fn.convertUrlToData
c3_chart_internal_fn.init
Chart
c3.generate
(anonymous)

1 个答案:

答案 0 :(得分:0)

如果“ js”代码存在,则会出现此错误

$('#test').vectorMap();

和“ html”代码不存在。

<div id="test"></div>