vue-plotly: Plots not updating on data changes
Hi there! I think the calls to Plotly.react may be broken? (or I could be changing them incorrectly … I just started Vue.js)
Try this in your App.vue to recreate it
<template>
<div id="app">
<plotly :data="plot_data" :layout="layout"></plotly>
<dat-gui closeText="Close controls" openText="Open controls" closePosition="bottom">
<dat-string v-model="layout.title" label="Title" />
<dat-number v-model="plot_data[0].y[0]" :min="-100" :max="100" :step="1" label="Offset y[0]"/>
</dat-gui>
<h3>{{layout}}</h3>
<h3>Y values are currently: {{this.plot_data[0].y}}</h3>
</div>
</template>
<script>
// the javascript below goes here
</script>
import {Plotly}from "vue-plotly";
import Vue from "vue";
import DatGui from "@cyrilf/vue-dat-gui";
Vue.use(DatGui);
export default {
name: "app",
components: { Plotly },
data() {
return {
layout: {
title: 'Plot update test'
},
plot_data: [{
x: [1,2,3,4],
y: [10, 15, 13, 17],
type: "scatter"
}]
};
},
};
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 28 (3 by maintainers)
Have a look at this demo for what I used to make statnett’s version reactive
The code of interest is here (albeit a bit messy 😨): https://github.com/Tehsurfer/vue-plotsvy/blob/netlify-hosting/src/App.vue
Ok for statnett! I must have found a special case. I found another one with this wrapper too anyway (I ve posted my “special” case in this issue #11) I actually use this wrapper and build my own component around it to fetch the data. So now you handle the call to plot or replot on your own, and you have a complete control on options, resposiveness? Might be a good idea for me too…
Ok, the issue was created a long time ago! Just as a side note, I’ve also tried the other vue plugin (the one from statnett) and experienced some problems with responsiveness. I would be interested to know about your solution, maybe directly by mail if you prefer!
Try plotly in lower case: