Fixed light-dark switch on chart demo

pull/4572/head
Cagatay Civici 2023-10-13 23:06:19 +03:00
parent 85ec13142b
commit 30804d993e
2 changed files with 13 additions and 0 deletions

View File

@ -32,6 +32,7 @@ export default {
this.$primevue.changeTheme(this.$appState.theme, event.theme, 'theme-link', () => { this.$primevue.changeTheme(this.$appState.theme, event.theme, 'theme-link', () => {
this.$appState.theme = event.theme; this.$appState.theme = event.theme;
this.$appState.darkTheme = event.dark; this.$appState.darkTheme = event.dark;
EventBus.emit('theme-change-complete', { theme: event.theme, dark: event.dark });
}); });
}; };

View File

@ -12,7 +12,10 @@
</template> </template>
<script> <script>
import EventBus from '@/layouts/AppEventBus';
export default { export default {
themeChangeListener: null,
data() { data() {
return { return {
chartData: null, chartData: null,
@ -163,9 +166,18 @@ const setChartOptions = () => {
} }
}; };
}, },
beforeUnmount() {
EventBus.off('theme-change-complete', this.themeChangeListener);
},
mounted() { mounted() {
this.chartData = this.setChartData(); this.chartData = this.setChartData();
this.chartOptions = this.setChartOptions(); this.chartOptions = this.setChartOptions();
this.themeChangeListener = () => {
this.chartOptions = this.setChartOptions();
};
EventBus.on('theme-change-complete', this.themeChangeListener);
}, },
methods: { methods: {
setChartData() { setChartData() {