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.$appState.theme = event.theme;
this.$appState.darkTheme = event.dark;
EventBus.emit('theme-change-complete', { theme: event.theme, dark: event.dark });
});
};

View File

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