-
-
Notifications
You must be signed in to change notification settings - Fork 826
Closed
Labels
Description
Expected Behavior
Chart should render after button click
Actual Behavior
Chart not rendering on button click but, does render button click after page refresh
Environment
- vue.js version: 3.0.0-beta.15
- vue-chart.js version: ^3.3.2
- npm version: 5.6.0
** these are versions I have to use at this time
Here is my code as I can't share the repo. I appreciate any feedback you might have.
----- Chart.vue (chart setup here)
import VueChart from 'vue-chartjs'
import { Line, mixins } from 'vue-chartjs'
export default {
extends: VueChart.Line,
mixins: [mixins.reactiveProp],
props: ['options'],
mounted() {
Chart.defaults.global.legend.labels.usePointStyle = true;
Chart.defaults.global.legend.display = false;
this.renderChart({
labels: ['Apr10', 'June10', 'Aug20'],
datasets: [{
label: 'Overview',
backgroundColor: '#0085D8',
data: this.chartData
}],
options: {}
}, {responsive: true, maintainAspectRatio: false})
}
}
--- Dashboard.vue (chart displays here, chart renders on button click, button click will toggle hide/show chart)
<template>
<el-button @click="toggle()">Click</el-button> // loaded/!loaded
<div class="dash-main-content-chart" v-if="loaded">
<dash-board-chart v-if="loaded" :chart-data="datapoints" :chart-labels="labels">
</dash-board-chart>
</div>
</template>
export default {
data() {
return {
datapoints: Array // used 'null' here as well
}
},
props: {
obj: Object
},
methods: {
fillChart() {
this.datapoints = [this.obj.thirtyTotal, this.obj.sixtyTotal, this.obj.yearToDate] // these are the 3 data points from object referenced in props
}
},
components: {
DashBoardChart
},
mounted() {
this.fillChart();
}
}