当超过10个数据对时,Chrome中的凹陷折线图无法正确绘制

时间:2015-03-24 23:28:18

标签: google-chrome dimple.js

我创建了一个jsfiddle,可以让你看到我的问题。该问题仅发生在Chrome中。最新版本的Safari,IE,FF完美运行。这是一个已知的问题?有修复吗?没有Dimple的D3工作正常。任何关于解决方案的想法或知识都会很棒。

http://jsfiddle.net/ernieb0y/0ovteqr8/1/

`var data1 = [{"距离":" 31","方差":0.11},          {"距离":" 92""差额":0.38},          {"距离":" 153""差额":0.84},          {"距离":" 214""差额":1.55},          {"距离":" 276""差额":2.34},          {"距离":" 337""差额":3.04},          {"距离":" 398""差额":3.86},          {"距离":" 459""差额":4.6},          {"距离":" 521""差额":5.16},          {"距离":" 582""差额":6.09},         ]     var data2 = [{"距离":" 31","方差":0.11},              {"距离":" 92""差额":0.38},              {"距离":" 153""差额":0.84},              {"距离":" 214""差额":1.55},              {"距离":" 276""差额":2.34},              {"距离":" 337""差额":3.04},              {"距离":" 398""差额":3.86},              {"距离":" 459""差额":4.6},              {"距离":" 521""差额":5.16},              {"距离":" 582""差额":6.09},              {"距离":" 643""差额":6.89},             ]

var svg = dimple.newSvg("#chartContainer", 600,600);

  var myChart = new dimple.chart(svg);
  myChart.setBounds(90, 35, 480, 400)
  xAxis = myChart.addMeasureAxis("x", "distance");
  yAxis = myChart.addMeasureAxis("y", "variance");
  xAxis.showGridlines = true;
  yAxis.ticks = 5 
  xAxis.ticks = 5 
  s1 = myChart.addSeries(["distance","perf_1"], dimple.plot.line, [xAxis, yAxis]);
  s1.data = data1
  s1.lineMarkers = true;
  s2 = myChart.addSeries(["distance","perf_2"], dimple.plot.line, [xAxis, yAxis]);
  s2.data = data2
  myChart.addLegend(90, 480, 330, 20, "left");
  myChart.draw();`

1 个答案:

答案 0 :(得分:0)

问题不在于数据,而在于使用addSeries调用。我在这里调整了它们:

请参阅小提琴:http://jsfiddle.net/jose_jimenez/nvrekzd5/1/

当您传递数组['distance','perf1']时,它希望每个都是一列,它具有创建图例的副作用。

如果你想要两个具有相似轴的系列,你可以在你的数据集中添加一个列(字段名称perf,值'perf1','perf2'),这样就可以得到你想要的东西。

http://jsfiddle.net/jose_jimenez/nvrekzd5/2/

(为了便于说明,调整为略有不同的值)

var data1 = [{"perf": 'perf1', "distance":"31","variance":0.11},
     {"perf": 'perf1', "distance":"92","variance":0.38},
     {"perf": 'perf1', "distance":"153","variance":0.84},
     {"perf": 'perf2', "distance":"31","variance":0.12},
         {"perf": 'perf2', "distance":"94","variance":0.38},
         {"perf": 'perf2', "distance":"150","variance":0.87},
         ]

var svg = dimple.newSvg("#chartContainer", 600,600);

  var myChart = new dimple.chart(svg);
  myChart.setBounds(90, 35, 480, 400)
  xAxis = myChart.addMeasureAxis("x", "distance");
  yAxis = myChart.addMeasureAxis("y", "variance");
  xAxis.showGridlines = true;
  yAxis.ticks = 5 
  xAxis.ticks = 5 
  s1 = myChart.addSeries(["distance", 'perf'], dimple.plot.line, [xAxis, yAxis]);
  s1.data = data1
  s1.lineMarkers = true;
  myChart.addLegend(90, 480, 330, 20, "left");
  myChart.draw();