Skip to content

Commit

Permalink
✨ make charts follow theme color
Browse files Browse the repository at this point in the history
  • Loading branch information
doroudi committed Dec 29, 2024
1 parent 5a05958 commit ad1b39c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { dialogRtl } from 'naive-ui/es/dialog/styles'
import { drawerRtl } from 'naive-ui/es/drawer/styles'
import { darkTheme, lightTheme } from 'naive-ui'
import useColors from './composables/colors'
import themeOverrides from '~/common/theme/theme-overrides'
const layout = useLayoutStore()
Expand All @@ -28,6 +29,7 @@ const rtlStyles = [
]
const customTheme = ref({ ...themeOverrides })
const { makeDarker, makeLighter } = useColors()

Check warning on line 32 in src/App.vue

View workflow job for this annotation

GitHub Actions / lint

'makeDarker' is assigned a value but never used. Allowed unused vars must match /^_/u
watch(() => layout.activeLanguage, () => {
const body = document.querySelector('body') as HTMLElement
Expand All @@ -50,6 +52,9 @@ watch(() => layout.themeColor, (newValue) => {
if (customTheme.value.common && newValue !== '') {
customTheme.value.common.primaryColor = newValue
document.documentElement.style.setProperty('--primary-color', newValue)
document.documentElement.style.setProperty('--primary-color-shade1', makeLighter(newValue, 0.8))
document.documentElement.style.setProperty('--primary-color-shade2', makeLighter(newValue, 0.6))
document.documentElement.style.setProperty('--primary-color-shade3', makeLighter(newValue, 0.4))
}
}, { immediate: true })
</script>
Expand Down
4 changes: 1 addition & 3 deletions src/components/BarChart.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script setup>
import { ref } from 'vue'
import VueApexCharts from 'vue3-apexcharts'
import useColors from '~/composables/colors'
const chartOptions = ref({
chart: {
Expand Down Expand Up @@ -43,7 +42,7 @@ const chartOptions = ref({
dataLabels: {
enabled: false,
},
colors: useColors().buildThemeColorSeries(2),
colors: ['var(--primary-color)', 'var(--primary-color-shade1)'],
plotOptions: {
bar: {
columnWidth: '17%',
Expand All @@ -56,7 +55,6 @@ const chartOptions = ref({
style: {
colors: '#6E6B7B',
fontSize: '0.86rem',
},
},
},
Expand Down
3 changes: 1 addition & 2 deletions src/components/DonutChart.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script setup lang="ts">
import VueApexCharts from 'vue3-apexcharts'
import { ref } from 'vue'
import useColors from '~/composables/colors'
const donutChartOptions = ref({
chart: {
Expand Down Expand Up @@ -34,7 +33,7 @@ const donutChartOptions = ref({
curve: 'smooth',
lineCap: 'round',
},
colors: useColors().buildThemeColorSeries(4),
colors: ['var(--primary-color)', 'var(--primary-color-shade1)', 'var(--primary-color-shade2)', 'var(--primary-color-shade3)'],
grid: {
padding: {
right: -20,
Expand Down

0 comments on commit ad1b39c

Please sign in to comment.