statnett / vue-plotly

A vue wrapper for plotly.js chart library
MIT License
119 stars 28 forks source link

Question: using of methods #22

Open joeSaad opened 5 years ago

joeSaad commented 5 years ago

Question: How do I use react method and redraw? I am having the data updated with another fetch from the backend but it is not reflecting the change in the chart.

Thanks

nicomoya123 commented 5 years ago
<vue-plotly
                        :data="plotTelems(inv.telems)"
                        :layout="layout"
                        :options="layouts.options"
                      />

plotTelems(data) {
      let time = data.map(a => a.time);
      let foo= data.map(a => a.foo);
      let trace1 = {
        name: "foo",
        x: time,
        y: foo,
        type: "scatter",
        yaxis: "y"
      };
      let pData = [trace1];
      return pData);
    },

If you give example i could help you more