|
|
@@ -11,8 +11,8 @@
|
|
11
|
11
|
const bar = ref(null)
|
|
12
|
12
|
const props = defineProps({
|
|
13
|
13
|
chartsData: {
|
|
14
|
|
- type: Object,
|
|
15
|
|
- default: () => ([])
|
|
|
14
|
+ type: Array,
|
|
|
15
|
+ default: () => []
|
|
16
|
16
|
}
|
|
17
|
17
|
})
|
|
18
|
18
|
const countryColors = ['#71B138', '#F801FA', '#6DA6FE', '#95E530', '#9963FB', '#FCE661', '#22C2CC', '#F76723']
|
|
|
@@ -41,39 +41,59 @@
|
|
41
|
41
|
}
|
|
42
|
42
|
}
|
|
43
|
43
|
const setChartsOptionsBar = computed(() => {
|
|
44
|
|
- const group = props.chartsData.reduce((cur,acc) => {
|
|
45
|
|
- let curItem = cur.find(item => item.groupName === acc.groupName)
|
|
46
|
|
- if (curItem) {
|
|
47
|
|
- curItem.seizeNums.push(acc.seizeQuantity)
|
|
48
|
|
- curItem.recordDates.push(acc.recordDate)
|
|
49
|
|
- } else {
|
|
50
|
|
- curItem = {
|
|
51
|
|
- groupName: acc.groupName,
|
|
52
|
|
- seizeNums: [acc.seizeQuantity],
|
|
53
|
|
- recordDates: [acc.recordDate]
|
|
54
|
|
- }
|
|
55
|
|
- cur.push(curItem)
|
|
|
44
|
+ const rawData = props.chartsData
|
|
|
45
|
+ if (!rawData || rawData.length === 0) return {}
|
|
|
46
|
+
|
|
|
47
|
+ const dates = rawData.map(item => item.recordDate)
|
|
|
48
|
+
|
|
|
49
|
+ const groupMap = {}
|
|
|
50
|
+ rawData.forEach(day => {
|
|
|
51
|
+ if (day.items && day.items.length > 0) {
|
|
|
52
|
+ day.items.forEach(item => {
|
|
|
53
|
+ if (!groupMap[item.groupName]) {
|
|
|
54
|
+ groupMap[item.groupName] = []
|
|
|
55
|
+ }
|
|
|
56
|
+ groupMap[item.groupName].push(item.seizeQuantity)
|
|
|
57
|
+ })
|
|
56
|
58
|
}
|
|
57
|
|
- return cur
|
|
58
|
|
- }, [])
|
|
59
|
|
- console.log(group);
|
|
60
|
|
-
|
|
|
59
|
+ })
|
|
|
60
|
+
|
|
|
61
|
+ const groupNames = Object.keys(groupMap)
|
|
|
62
|
+ const legendData = groupNames.slice(0, 20)
|
|
|
63
|
+ const seriesData = groupNames.slice(0, 20)
|
|
|
64
|
+
|
|
61
|
65
|
return {
|
|
62
|
66
|
grid: {
|
|
63
|
67
|
top: 40,
|
|
64
|
|
- bottom: 30,
|
|
|
68
|
+ bottom: 60,
|
|
65
|
69
|
left: 60,
|
|
66
|
70
|
right: 20
|
|
67
|
71
|
},
|
|
68
|
72
|
legend: {
|
|
69
|
|
- show: true
|
|
|
73
|
+ show: true,
|
|
|
74
|
+ textStyle: { color: '#fff', fontSize: 11 }
|
|
70
|
75
|
},
|
|
|
76
|
+ dataZoom: [
|
|
|
77
|
+ {
|
|
|
78
|
+ type: 'slider',
|
|
|
79
|
+ bottom: 10,
|
|
|
80
|
+ height: 20,
|
|
|
81
|
+ borderColor: 'rgba(112,207,231,0.3)',
|
|
|
82
|
+ backgroundColor: 'rgba(13,80,122,0.3)',
|
|
|
83
|
+ fillerColor: 'rgba(112,207,231,0.2)',
|
|
|
84
|
+ handleStyle: {
|
|
|
85
|
+ color: '#70CFE7'
|
|
|
86
|
+ },
|
|
|
87
|
+ textStyle: { color: '#fff' },
|
|
|
88
|
+ labelFormatter: (value) => dates[value] || ''
|
|
|
89
|
+ }
|
|
|
90
|
+ ],
|
|
71
|
91
|
xAxis: {
|
|
72
|
92
|
type: 'category',
|
|
73
|
|
- axisLabel: { show: false },
|
|
74
|
|
- axisLine: { show: false },
|
|
|
93
|
+ axisLabel: { color: '#fff', fontSize: 11, rotate: 45 },
|
|
|
94
|
+ axisLine: { lineStyle: { color: '#344067' } },
|
|
75
|
95
|
boundaryGap: false,
|
|
76
|
|
- data: group.length ? group[0].recordDates : []
|
|
|
96
|
+ data: dates
|
|
77
|
97
|
},
|
|
78
|
98
|
yAxis: [
|
|
79
|
99
|
{
|
|
|
@@ -84,10 +104,10 @@
|
|
84
|
104
|
splitLine: { lineStyle: { color: '#344067' } }
|
|
85
|
105
|
},
|
|
86
|
106
|
],
|
|
87
|
|
- series: group.map((item, index) => {
|
|
|
107
|
+ series: seriesData.map((name, index) => {
|
|
88
|
108
|
return {
|
|
89
|
|
- name: item.groupName,
|
|
90
|
|
- data: item.seizeNums,
|
|
|
109
|
+ name,
|
|
|
110
|
+ data: groupMap[name],
|
|
91
|
111
|
...createItemConfig(index)
|
|
92
|
112
|
}
|
|
93
|
113
|
}),
|