-
-
Notifications
You must be signed in to change notification settings - Fork 838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: Chart not re-rendering on window resize #82
Comments
Mh, why should the chart re-render on window resize? 🤔 And you actually dont't need to re-render the chart on every data change. Theres also an |
@apertureless There has been some weird bug causing chart to not look properly after window resize, until it got new data (because then it re-rendered). Maybe this is specific to the enviroment I work in - Electron Edit: I have actually realised, that these two problems are pretty specific for my case. I need to render a chart based on which radio button is checked, you know like: |
I have a simliar problem, I use jbaysolutions/vue-grid-layout and render a barchart insede one of the grid Items. When a grid item gets resized, I would like the bar chart to resize properly. It only resized to the new size after it get new data, so it naturally re-renders. grid component: <grid-layout :layout="widgetsz" :col-num="12" :row-height="30" :is-draggable="true" :isresizable="true" :vertical-compact="true" :margin="[10, 10]" :use-css-transforms="true" >
<grid-item class="gridItem" v-for="widget in widgetsz" v-bind:key="widget.i">
<disposition :globaldata="node.dispositions" :popdata="node.popdispositions" :h="(widget.h*30)*0.9" :w="widget.w"/>
</grid-item>
</grid-layout> disposition.vue: <div>
<disposition-chart :styles="chartStyles" :chart-data="bardata" :width="w" :options="options" />
</div> <script>
import { Bar,mixins } from 'vue-chartjs'
export default {
extends: Bar,
props: ['options', 'width'],
mixins: [mixins.reactiveProp],
mounted () {
this.addPlugin({
id: 'plgin1',
beforeUpdate(chart) {
chart.config.data.labels.forEach(function (value, index, array) {
var a = [];
a.push(value.slice(0, 12));
var i = 1;
while(value.length > (i * 12)){
a.push(value.slice(i * 12, (i + 1) * 12));
i++;
}
array[index] = a;
})
},
})
this.renderChart(this.chartData, this.options)
},
}
</script> |
Expected Behavior
Re-render the chart on window resize.
Actual Behavior
Chart won't re-render until it gets new data, like I suggested in #10
What helped me to solve this
Notice that
window.addEventListener
I've added in. Can you please implement this globally or did you already and I am just missing something?The text was updated successfully, but these errors were encountered: