@@ -55,6 +55,7 @@
import { ref, onMounted, onBeforeUnmount } from 'vue'
import { useRouter } from 'vue-router'
import * as echarts from 'echarts'
+import { THEME } from '@/utils/chartTheme'
import { regionLabel } from '@/utils/region'
import { fetchOverviewStats } from '@/api/statistics'
@@ -71,10 +72,10 @@ const onResize = () => charts.forEach((chart) => chart.resize())
const initCharts = () => {
charts = [
- echarts.init(majorChart.value),
- echarts.init(subChart.value),
- echarts.init(brandChart.value),
- echarts.init(regionChart.value)
+ echarts.init(majorChart.value, THEME),
+ echarts.init(subChart.value, THEME),
+ echarts.init(brandChart.value, THEME),
+ echarts.init(regionChart.value, THEME)
]
}
@@ -91,26 +92,23 @@ const updateCharts = () => {
}))
charts[0].setOption({
tooltip: { trigger: 'item' },
- series: [
- {
- type: 'pie',
- radius: ['40%', '70%'],
- data: majorData
- }
- ]
+ series: [{
+ type: 'pie',
+ radius: ['40%', '70%'],
+ data: majorData
+ }]
})
const subData = stats.value.material_subcategory_stats || []
charts[1].setOption({
grid: { left: 80, right: 20, top: 20, bottom: 20 },
- xAxis: { type: 'value', axisLabel: { color: '#9fb3c8' } },
+ xAxis: { type: 'value' },
yAxis: {
type: 'category',
- data: subData.map((item) => item.material_subcategory),
- axisLabel: { color: '#9fb3c8' }
+ data: subData.map((item) => item.material_subcategory)
},
series: [
- { type: 'bar', data: subData.map((item) => item.count), itemStyle: { color: '#7cb4e3' } }
+ { type: 'bar', data: subData.map((item) => item.count), barWidth: '60%' }
]
})
@@ -119,31 +117,29 @@ const updateCharts = () => {
value: item.count
}))
charts[2].setOption({
- series: [
- {
- type: 'treemap',
- data: brandData,
- label: { show: true, color: '#0b121c' },
- itemStyle: {
- borderColor: '#0b121c'
- }
- }
- ]
+ tooltip: { trigger: 'item' },
+ series: [{
+ type: 'treemap',
+ data: brandData,
+ label: { show: true, color: '#e8f0f8', fontSize: 12 },
+ itemStyle: { borderColor: 'rgba(12, 24, 44, 0.6)', borderWidth: 2 },
+ levels: [{
+ itemStyle: { borderColor: 'rgba(12, 24, 44, 0.8)', borderWidth: 3, gapWidth: 3 }
+ }]
+ }]
})
const regionData = (stats.value.region_stats || []).map((item) => ({
- name: `${regionLabel(item.province)}-${regionLabel(item.city)}`,
+ name: regionLabel(item.province),
value: item.count
}))
charts[3].setOption({
tooltip: { trigger: 'item' },
- series: [
- {
- type: 'pie',
- radius: ['30%', '70%'],
- data: regionData
- }
- ]
+ series: [{
+ type: 'pie',
+ radius: ['30%', '70%'],
+ data: regionData
+ }]
})
}