statnett / vue-plotly

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

Plotly with API #24

Open ddiegommachado opened 5 years ago

ddiegommachado commented 5 years ago

Hi everyone,

I need mount a graph with data of the a API. I'm using https://github.com/statnett/vue-plotly My code is:

<vue-plotly :data="data" :layout="layout" :options="options" />
<script>
import axios from "axios";
import VuePlotly from "@statnett/vue-plotly";

export default {
  components: {
    VuePlotly
  },
  data() {
    return {
      fields: [],
      data: [{ x: [], y: [] }],
      layout: {},
      options: {},
      responsive: true
    };
  },
  mounted() {
    var url = "http://www.mocky.io/v2/5d77aa2f3200005b00923f71";

    axios.get(url).then(r => {
      this.fields = r.data.fields;
    });
  }
};
</script>

How make this?

glorat commented 4 years ago

<vue-plotly> references data, layout and options. There is no reference to fields so it is not surprising it does nothing