Showing
1 changed file
with
74 additions
and
8 deletions
@@ -8,6 +8,7 @@ | @@ -8,6 +8,7 @@ | ||
8 | // import { useIntervalFn } from '@vueuse/core'; | 8 | // import { useIntervalFn } from '@vueuse/core'; |
9 | import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; | 9 | import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; |
10 | import { useComponentScale } from '/@/views/visual/packages/hook/useComponentScale'; | 10 | import { useComponentScale } from '/@/views/visual/packages/hook/useComponentScale'; |
11 | + // import { SeriesOption } from 'echarts/types/dist/shared'; | ||
11 | 12 | ||
12 | const props = defineProps<{ | 13 | const props = defineProps<{ |
13 | config: ComponentPropsConfigType<typeof option>; | 14 | config: ComponentPropsConfigType<typeof option>; |
@@ -21,6 +22,27 @@ | @@ -21,6 +22,27 @@ | ||
21 | 22 | ||
22 | const getDesign = computed(() => { | 23 | const getDesign = computed(() => { |
23 | const { option, persetOption } = props.config; | 24 | const { option, persetOption } = props.config; |
25 | + // const { dataSource = [] } = option || {}; | ||
26 | + // const { | ||
27 | + // fontColor: persetFontColor, | ||
28 | + // unit: persetUnit, | ||
29 | + // showDeviceName: persetShowDeviceName, | ||
30 | + // } = persetOption || {}; | ||
31 | + // return { | ||
32 | + // dataSource: dataSource.map((item) => { | ||
33 | + // const { unit, fontColor, showDeviceName } = item.componentInfo || {}; | ||
34 | + // const { deviceName, deviceRename, attribute } = item; | ||
35 | + // return { | ||
36 | + // unit: unit ?? persetUnit, | ||
37 | + // fontColor: fontColor ?? persetFontColor, | ||
38 | + // showDeviceName: showDeviceName ?? persetShowDeviceName, | ||
39 | + // attribute, | ||
40 | + // deviceName, | ||
41 | + // deviceRename, | ||
42 | + // }; | ||
43 | + // }), | ||
44 | + // }; | ||
45 | + | ||
24 | const { componentInfo, attribute, attributeRename } = option; | 46 | const { componentInfo, attribute, attributeRename } = option; |
25 | const { | 47 | const { |
26 | fontColor: presetFontColor, | 48 | fontColor: presetFontColor, |
@@ -53,6 +75,7 @@ | @@ -53,6 +75,7 @@ | ||
53 | detail: { | 75 | detail: { |
54 | valueAnimation: true, | 76 | valueAnimation: true, |
55 | offsetCenter: ['0%', '-20%'], | 77 | offsetCenter: ['0%', '-20%'], |
78 | + // formatter: `{value} ℃`, | ||
56 | }, | 79 | }, |
57 | }, | 80 | }, |
58 | { | 81 | { |
@@ -64,14 +87,17 @@ | @@ -64,14 +87,17 @@ | ||
64 | detail: { | 87 | detail: { |
65 | valueAnimation: true, | 88 | valueAnimation: true, |
66 | offsetCenter: ['0%', '15%'], | 89 | offsetCenter: ['0%', '15%'], |
90 | + // formatter: `{value} ℃`, | ||
67 | }, | 91 | }, |
68 | }, | 92 | }, |
69 | ]; | 93 | ]; |
70 | 94 | ||
71 | const options = (): EChartsOption => { | 95 | const options = (): EChartsOption => { |
72 | const { fontColor } = unref(getDesign); | 96 | const { fontColor } = unref(getDesign); |
97 | + // const { fontColor, unit } = unref(getDesign).dataSource[0] || []; | ||
98 | + // console.log(fontColor, unit, 'unit', unref(getDesign)); | ||
73 | return { | 99 | return { |
74 | - color: ['#ED6C0D', '#D3DB00', '#00F0F0'], | 100 | + color: ['#377DFF', '#FD666D', '#00F0F0'], |
75 | series: [ | 101 | series: [ |
76 | { | 102 | { |
77 | type: 'gauge', | 103 | type: 'gauge', |
@@ -83,11 +109,11 @@ | @@ -83,11 +109,11 @@ | ||
83 | progress: { | 109 | progress: { |
84 | show: true, | 110 | show: true, |
85 | overlap: false, | 111 | overlap: false, |
86 | - roundCap: true, | 112 | + // roundCap: true, |
87 | clip: false, | 113 | clip: false, |
88 | itemStyle: { | 114 | itemStyle: { |
89 | - // borderWidth: 1, | ||
90 | - // borderColor: '#464646', | 115 | + borderWidth: 1, |
116 | + borderColor: '#464646', | ||
91 | }, | 117 | }, |
92 | }, | 118 | }, |
93 | axisLine: { | 119 | axisLine: { |
@@ -144,9 +170,11 @@ | @@ -144,9 +170,11 @@ | ||
144 | // }); | 170 | // }); |
145 | // }, 3000); | 171 | // }, 3000); |
146 | // }; | 172 | // }; |
173 | + | ||
147 | const list = ref<any>([]); | 174 | const list = ref<any>([]); |
148 | const updateFn: MultipleDataFetchUpdateFn = (message) => { | 175 | const updateFn: MultipleDataFetchUpdateFn = (message) => { |
149 | const { data = {} } = message; | 176 | const { data = {} } = message; |
177 | + | ||
150 | const { dataSource } = props.config.option; | 178 | const { dataSource } = props.config.option; |
151 | // const dataList = Object.keys(data); | 179 | // const dataList = Object.keys(data); |
152 | const dataList = dataSource?.map((item) => item.attribute); | 180 | const dataList = dataSource?.map((item) => item.attribute); |
@@ -167,9 +195,14 @@ | @@ -167,9 +195,14 @@ | ||
167 | }); | 195 | }); |
168 | dataSource?.forEach((item, index) => { | 196 | dataSource?.forEach((item, index) => { |
169 | list.value.forEach((item1, index1) => { | 197 | list.value.forEach((item1, index1) => { |
198 | + console.log(item, 'item'); | ||
170 | if (index == index1) { | 199 | if (index == index1) { |
171 | // item1.value = item1.value + item.componentInfo.unit; | 200 | // item1.value = item1.value + item.componentInfo.unit; |
172 | - item1.name = item.attributeRename; | 201 | + item1.name = item.componentInfo.showDeviceName |
202 | + ? item.deviceRename | ||
203 | + ? item.deviceRename | ||
204 | + : item.deviceName | ||
205 | + : ''; | ||
173 | item1.title.color = item.componentInfo.fontColor; | 206 | item1.title.color = item.componentInfo.fontColor; |
174 | item1.detail.color = item.componentInfo.fontColor; | 207 | item1.detail.color = item.componentInfo.fontColor; |
175 | item1.detail.formatter = `{value} ${item.componentInfo.unit ?? ''}`; | 208 | item1.detail.formatter = `{value} ${item.componentInfo.unit ?? ''}`; |
@@ -182,9 +215,42 @@ | @@ -182,9 +215,42 @@ | ||
182 | color: unref(list).map((item) => item.title.color), | 215 | color: unref(list).map((item) => item.title.color), |
183 | } as EChartsOption); | 216 | } as EChartsOption); |
184 | 217 | ||
185 | - // updateChart(isNaN(value as unknown as number) ? 0 : Number(value)); | 218 | + // const { dataSource } = unref(getDesign); |
219 | + // const series = dataSource.map((item, index) => { | ||
220 | + // const { unit, fontColor, showDeviceName, attribute, deviceName, deviceRename } = item; | ||
221 | + // const [latest] = data[attribute] || []; | ||
222 | + // const [_timespan, value] = latest || []; | ||
223 | + // return { | ||
224 | + // value, | ||
225 | + // name: showDeviceName ? (deviceRename ? deviceRename : deviceName) : '', | ||
226 | + // title: { | ||
227 | + // color: fontColor, | ||
228 | + // offsetCenter: index == 0 ? ['0%', '-35%'] : index == 1 ? ['0%', '0%'] : ['0%', '35%'], | ||
229 | + // }, | ||
230 | + // detail: { | ||
231 | + // color: fontColor, | ||
232 | + // valueAnimation: true, | ||
233 | + // offsetCenter: index == 0 ? ['0%', '-20%'] : index == 1 ? ['0%', '18%'] : ['0%', '50%'], | ||
234 | + // formatter: `{value} ${unit ?? ''}`, | ||
235 | + // }, | ||
236 | + // } as SeriesOption['data']; | ||
237 | + // }); | ||
238 | + // const xAxisData = dataSource.map((item: any) => item.fontColor as any); | ||
239 | + // console.log(series, xAxisData, 'xAxisData'); | ||
240 | + // unref(chartInstance)?.setOption({ | ||
241 | + // series: [{ data: series, pointer: { show: false } }], | ||
242 | + // color: xAxisData as any, | ||
243 | + // }); | ||
244 | + // updateChart(series, xAxisData); | ||
186 | }; | 245 | }; |
187 | 246 | ||
247 | + // const updateChart = (data: SeriesOption['data'], xAxisData) => { | ||
248 | + // unref(chartInstance)?.setOption({ | ||
249 | + // series: [{ data }], | ||
250 | + // xAxis: { data: xAxisData }, | ||
251 | + // }); | ||
252 | + // }; | ||
253 | + | ||
188 | useMultipleDataFetch(props, updateFn); | 254 | useMultipleDataFetch(props, updateFn); |
189 | 255 | ||
190 | onMounted(() => { | 256 | onMounted(() => { |
@@ -229,9 +295,9 @@ | @@ -229,9 +295,9 @@ | ||
229 | <main class="w-full h-full flex flex-col justify-center items-center"> | 295 | <main class="w-full h-full flex flex-col justify-center items-center"> |
230 | <DeviceName :config="config" /> | 296 | <DeviceName :config="config" /> |
231 | <div ref="chartRefEl" class="flex-1 w-full h-full"> </div> | 297 | <div ref="chartRefEl" class="flex-1 w-full h-full"> </div> |
232 | - <div class="text-gray-500 text-xs text-center truncate">{{ | 298 | + <!-- <div class="text-gray-500 text-xs text-center truncate">{{ |
233 | getDesign.attribute || '湿度' | 299 | getDesign.attribute || '湿度' |
234 | - }}</div> | 300 | + }}</div> --> |
235 | <UpdateTime :time="time" /> | 301 | <UpdateTime :time="time" /> |
236 | </main> | 302 | </main> |
237 | </template> | 303 | </template> |