Chart demo updates

pull/4649/head
Tuğçe Küçükoğlu 2023-10-17 16:12:53 +03:00
parent a37fb0d010
commit ff35703343
11 changed files with 126 additions and 16 deletions

View File

@ -9,6 +9,8 @@
</template> </template>
<script> <script>
import EventBus from '@/layouts/AppEventBus';
export default { export default {
data() { data() {
return { return {
@ -204,6 +206,12 @@ const setChartOptions = () => {
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() {

View File

@ -9,13 +9,13 @@
</template> </template>
<script> <script>
import EventBus from '@/layouts/AppEventBus';
export default { export default {
data() { data() {
return { return {
chartData: null, chartData: null,
chartOptions: { chartOptions: null,
cutout: '60%'
},
code: { code: {
basic: ` basic: `
<Chart type="doughnut" :data="chartData" :options="chartOptions" class="w-full md:w-30rem" /> <Chart type="doughnut" :data="chartData" :options="chartOptions" class="w-full md:w-30rem" />
@ -99,10 +99,17 @@ const setChartData = () => {
}, },
mounted() { mounted() {
this.chartData = this.setChartData(); this.chartData = this.setChartData();
this.chartOptions = this.setChartOptions();
this.themeChangeListener = () => {
this.chartOptions = this.setChartOptions();
};
EventBus.on('theme-change-complete', this.themeChangeListener);
}, },
methods: { methods: {
setChartData() { setChartData() {
const documentStyle = getComputedStyle(document.body); const documentStyle = getComputedStyle(document.documentElement);
return { return {
labels: ['A', 'B', 'C'], labels: ['A', 'B', 'C'],
@ -114,6 +121,21 @@ const setChartData = () => {
} }
] ]
}; };
},
setChartOptions() {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color');
return {
plugins: {
legend: {
labels: {
cutout: '60%',
color: textColor
}
}
}
};
} }
} }
}; };

View File

@ -9,6 +9,8 @@
</template> </template>
<script> <script>
import EventBus from '@/layouts/AppEventBus';
export default { export default {
data() { data() {
return { return {
@ -194,6 +196,12 @@ const setChartOptions = () => {
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() {
@ -230,7 +238,7 @@ const setChartOptions = () => {
plugins: { plugins: {
legend: { legend: {
labels: { labels: {
fontColor: textColor color: textColor
} }
} }
}, },

View File

@ -9,6 +9,8 @@
</template> </template>
<script> <script>
import EventBus from '@/layouts/AppEventBus';
export default { export default {
data() { data() {
return { return {
@ -186,6 +188,12 @@ const setChartOptions = () => {
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() {

View File

@ -9,6 +9,8 @@
</template> </template>
<script> <script>
import EventBus from '@/layouts/AppEventBus';
export default { export default {
data() { data() {
return { return {
@ -204,6 +206,12 @@ const setChartOptions = () => {
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() {

View File

@ -9,6 +9,8 @@
</template> </template>
<script> <script>
import EventBus from '@/layouts/AppEventBus';
export default { export default {
data() { data() {
return { return {
@ -222,6 +224,12 @@ const setChartOptions = () => {
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() {

View File

@ -9,19 +9,13 @@
</template> </template>
<script> <script>
import EventBus from '@/layouts/AppEventBus';
export default { export default {
data() { data() {
return { return {
chartData: null, chartData: null,
chartOptions: { chartOptions: null,
plugins: {
legend: {
labels: {
usePointStyle: true
}
}
}
},
code: { code: {
basic: ` basic: `
<Chart type="pie" :data="chartData" :options="chartOptions" class="w-full md:w-30rem" /> <Chart type="pie" :data="chartData" :options="chartOptions" class="w-full md:w-30rem" />
@ -117,10 +111,17 @@ const setChartData = () => {
}, },
mounted() { mounted() {
this.chartData = this.setChartData(); this.chartData = this.setChartData();
this.chartOptions = this.setChartOptions();
this.themeChangeListener = () => {
this.chartOptions = this.setChartOptions();
};
EventBus.on('theme-change-complete', this.themeChangeListener);
}, },
methods: { methods: {
setChartData() { setChartData() {
const documentStyle = getComputedStyle(document.body); const documentStyle = getComputedStyle(document.documentElement);
return { return {
labels: ['A', 'B', 'C'], labels: ['A', 'B', 'C'],
@ -132,6 +133,21 @@ const setChartData = () => {
} }
] ]
}; };
},
setChartOptions() {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color');
return {
plugins: {
legend: {
labels: {
usePointStyle: true,
color: textColor
}
}
}
};
} }
} }
}; };

View File

@ -9,6 +9,8 @@
</template> </template>
<script> <script>
import EventBus from '@/layouts/AppEventBus';
export default { export default {
data() { data() {
return { return {
@ -152,6 +154,12 @@ const setChartOptions = () => {
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() {

View File

@ -9,6 +9,8 @@
</template> </template>
<script> <script>
import EventBus from '@/layouts/AppEventBus';
export default { export default {
data() { data() {
return { return {
@ -168,6 +170,12 @@ const setChartOptions = () => {
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() {

View File

@ -9,6 +9,8 @@
</template> </template>
<script> <script>
import EventBus from '@/layouts/AppEventBus';
export default { export default {
data() { data() {
return { return {
@ -206,6 +208,12 @@ const setChartOptions = () => {
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() {

View File

@ -9,6 +9,8 @@
</template> </template>
<script> <script>
import EventBus from '@/layouts/AppEventBus';
export default { export default {
data() { data() {
return { return {
@ -192,6 +194,12 @@ const setChartOptions = () => {
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() {
@ -227,7 +235,7 @@ const setChartOptions = () => {
plugins: { plugins: {
legend: { legend: {
labels: { labels: {
fontColor: textColor color: textColor
} }
} }
}, },