|
@@ -12,13 +12,17 @@ import {
|
|
|
onMounted,
|
|
|
watch,
|
|
|
nextTick,
|
|
|
+ computed,
|
|
|
} from 'vue'
|
|
|
import * as echarts from 'echarts'
|
|
|
+import { useAppStore } from '@/stores'
|
|
|
+import { extractRgbFromRgba, hexToRgb } from '@/utils/czr-util'
|
|
|
|
|
|
const props = defineProps({
|
|
|
data: <any>{},
|
|
|
})
|
|
|
|
|
|
+const AppStore = useAppStore()
|
|
|
const { proxy } = getCurrentInstance()
|
|
|
const state = reactive({
|
|
|
resizeObserver: <any>null,
|
|
@@ -26,6 +30,15 @@ const state = reactive({
|
|
|
})
|
|
|
const ref_chart = ref()
|
|
|
const ref_main = ref()
|
|
|
+const colorCpt1 = computed(() => {
|
|
|
+ if (AppStore.themeColor) {
|
|
|
+ return `rgba(${extractRgbFromRgba(hexToRgb(AppStore.themeColor)).join(',')}, 0.8)`
|
|
|
+ }
|
|
|
+})
|
|
|
+const colorCpt2 = computed(
|
|
|
+ () =>
|
|
|
+ `rgba(${extractRgbFromRgba(hexToRgb(AppStore.themeColor)).join(',')}, 0.6)`,
|
|
|
+)
|
|
|
const initChart = () => {
|
|
|
echarts.dispose(ref_chart.value)
|
|
|
const chart = echarts.init(ref_chart.value)
|
|
@@ -91,7 +104,7 @@ const initChart = () => {
|
|
|
type: 'bar',
|
|
|
data: props.data.map((v) => v.solvingCount || 0),
|
|
|
itemStyle: {
|
|
|
- color: 'rgba(211, 73, 71, 1)',
|
|
|
+ color: colorCpt1.value,
|
|
|
},
|
|
|
},
|
|
|
{
|
|
@@ -100,7 +113,7 @@ const initChart = () => {
|
|
|
type: 'bar',
|
|
|
data: props.data.map((v) => Math.abs(v.unSolvingCount) || 0),
|
|
|
itemStyle: {
|
|
|
- color: 'rgba(2, 50, 112, 1)',
|
|
|
+ color: colorCpt2.value,
|
|
|
},
|
|
|
},
|
|
|
],
|
|
@@ -115,7 +128,7 @@ const initChart = () => {
|
|
|
return chart
|
|
|
}
|
|
|
watch(
|
|
|
- () => props.data,
|
|
|
+ () => [props.data, AppStore.themeColor],
|
|
|
() => {
|
|
|
state.chart = initChart()
|
|
|
},
|