85 lines
2.4 KiB
Vue
Executable File
85 lines
2.4 KiB
Vue
Executable File
<template>
|
|
<div>
|
|
<div class="content-section introduction">
|
|
<div class="feature-intro">
|
|
<h1>DoughnutChart</h1>
|
|
<p>A doughnut chart is a variant of the pie chart, with a blank center allowing for additional information about the data as a whole to be included.</p>
|
|
</div>
|
|
<AppDemoActions />
|
|
</div>
|
|
|
|
<div class="content-section implementation">
|
|
<div class="card flex justify-content-center">
|
|
<Chart type="doughnut" :data="chartData" :options="chartOptions" style="width: 40%" />
|
|
</div>
|
|
</div>
|
|
|
|
<DoughnutChartDoc />
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import EventBus from '@/layouts/AppEventBus';
|
|
import DoughnutChartDoc from './DoughnutChartDoc';
|
|
|
|
export default {
|
|
themeChangeListener: null,
|
|
data() {
|
|
return {
|
|
chartData: {
|
|
labels: ['A', 'B', 'C'],
|
|
datasets: [
|
|
{
|
|
data: [300, 50, 100],
|
|
backgroundColor: ['#FF6384', '#36A2EB', '#FFCE56'],
|
|
hoverBackgroundColor: ['#FF6384', '#36A2EB', '#FFCE56']
|
|
}
|
|
]
|
|
},
|
|
chartOptions: this.isDarkTheme() ? this.getDarkTheme() : this.getLightTheme()
|
|
};
|
|
},
|
|
mounted() {
|
|
this.themeChangeListener = (event) => {
|
|
if (event.dark) this.chartOptions = this.getDarkTheme();
|
|
else this.chartOptions = this.getLightTheme();
|
|
};
|
|
|
|
EventBus.on('theme-change', this.themeChangeListener);
|
|
},
|
|
beforeUnmount() {
|
|
EventBus.off('change-theme', this.themeChangeListener);
|
|
},
|
|
methods: {
|
|
isDarkTheme() {
|
|
return this.$appState.darkTheme === true;
|
|
},
|
|
getLightTheme() {
|
|
return {
|
|
plugins: {
|
|
legend: {
|
|
labels: {
|
|
color: '#495057'
|
|
}
|
|
}
|
|
}
|
|
};
|
|
},
|
|
getDarkTheme() {
|
|
return {
|
|
plugins: {
|
|
legend: {
|
|
labels: {
|
|
color: '#ebedef'
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
},
|
|
components: {
|
|
DoughnutChartDoc: DoughnutChartDoc
|
|
}
|
|
};
|
|
</script>
|