如何将数据附加到c3.js中的系列?

时间:2018-05-31 18:28:33

标签: javascript c3.js

我想要更新图表,因为数据来自mqtt频道。但是,我没有看到如何在正确的消息上附加steps系列。

  var chart = c3.generate({
    bindto: '#epoch-report',
    data: {
     columns: [
       ['steps',]
     ]
   },
   axis:{
      x: {
        max: .1,
        label: {
          text: "Epoch"
        }
      },
      y: {
        max: .1,
        label: {
          text: "Step",
        }
      }
   }
  });
  if (topic == "/epoch/update") {
    var j = JSON.parse(new TextDecoder("utf-8").decode(payload));
    var msg = "<br> Epoch: " + j.id + " steps: " + j.steps + " winner: " + j.winner;
    document.getElementById('epoch-report').innerHTML += msg;
    console.log("Now I want to add data to ");
    console.log(chart.data.values);
  } else if (topic == "/epoch/setup") {
    var j = JSON.parse(new TextDecoder("utf-8").decode(payload));
    console.log("setting up epoch dash with max steps " + j.maxsteps);
  }

我似乎无法访问chart.data.columns['step']或类似内容。如何添加到steps

0 个答案:

没有答案