|
13 | 13 | </div> |
14 | 14 | </template> |
15 | 15 |
|
16 | | -<script lang="ts" setup> |
17 | | -import * as echarts from 'echarts/core'; |
18 | | -import { |
19 | | - ToolboxComponent, |
20 | | - ToolboxComponentOption, |
21 | | - TooltipComponent, |
22 | | - TooltipComponentOption, |
23 | | - GridComponent, |
24 | | - GridComponentOption, |
25 | | - DataZoomComponent, |
26 | | - DataZoomComponentOption |
27 | | -} from 'echarts/components'; |
28 | | -import { LineChart, LineSeriesOption } from 'echarts/charts'; |
29 | | -import { UniversalTransition } from 'echarts/features'; |
30 | | -import { CanvasRenderer } from 'echarts/renderers'; |
31 | | -import { onMounted } from 'vue'; |
32 | | -import { EChartsType } from 'echarts/core'; |
33 | | -import socket from '../script/websocket' |
34 | | -
|
35 | | -import { ref } from "vue"; |
36 | | -import { |
37 | | - ElFormItem, |
38 | | - ElInputNumber, |
39 | | - ElButton, |
40 | | - ElMessage |
41 | | -} from 'element-plus' |
42 | | -
|
43 | | -echarts.use([ |
44 | | - ToolboxComponent, |
45 | | - TooltipComponent, |
46 | | - GridComponent, |
47 | | - DataZoomComponent, |
48 | | - LineChart, |
49 | | - CanvasRenderer, |
50 | | - UniversalTransition |
51 | | -]); |
52 | | -
|
53 | | -
|
54 | | -// 2.定义传入的参数 |
55 | | -const props = defineProps({ |
56 | | - width: { |
57 | | - type: String, |
58 | | - default: "550", |
59 | | - }, |
60 | | - height: { |
61 | | - type: String, |
62 | | - default: "350", |
63 | | - }, |
64 | | - //首次加载 |
65 | | - isFirst: { |
66 | | - type: Boolean, |
67 | | - default: false, |
68 | | - }, |
69 | | - //组件唯一值 |
70 | | - container: { |
71 | | - type: String, |
72 | | - default: "OSCChart", |
73 | | - }, |
74 | | -}); |
75 | | -
|
76 | | -
|
77 | | -
|
78 | | -onMounted(() => { |
79 | | - chartDom = document.getElementById(props.container) as HTMLElement |
80 | | - myChart = echarts.init(chartDom); |
81 | | - option && myChart.setOption(option); |
82 | | -}) |
83 | | -
|
84 | | -</script> |
85 | | - |
86 | 16 | <script lang="ts"> |
| 17 | +import { ref } from "vue"; |
87 | 18 | type EChartsOption = echarts.ComposeOption< |
88 | 19 | | ToolboxComponentOption |
89 | 20 | | TooltipComponentOption |
@@ -259,6 +190,78 @@ export default { |
259 | 190 |
|
260 | 191 | </script> |
261 | 192 |
|
| 193 | + |
| 194 | +<script lang="ts" setup> |
| 195 | +import * as echarts from 'echarts/core'; |
| 196 | +import { |
| 197 | + ToolboxComponent, |
| 198 | + ToolboxComponentOption, |
| 199 | + TooltipComponent, |
| 200 | + TooltipComponentOption, |
| 201 | + GridComponent, |
| 202 | + GridComponentOption, |
| 203 | + DataZoomComponent, |
| 204 | + DataZoomComponentOption |
| 205 | +} from 'echarts/components'; |
| 206 | +import { LineChart, LineSeriesOption } from 'echarts/charts'; |
| 207 | +import { UniversalTransition } from 'echarts/features'; |
| 208 | +import { CanvasRenderer } from 'echarts/renderers'; |
| 209 | +import { onMounted } from 'vue'; |
| 210 | +import { EChartsType } from 'echarts/core'; |
| 211 | +import socket from '../script/websocket' |
| 212 | +
|
| 213 | +
|
| 214 | +import { |
| 215 | + // ElFormItem, |
| 216 | + // ElInputNumber, |
| 217 | + // ElButton, |
| 218 | + ElMessage |
| 219 | +} from 'element-plus' |
| 220 | +
|
| 221 | +echarts.use([ |
| 222 | + ToolboxComponent, |
| 223 | + TooltipComponent, |
| 224 | + GridComponent, |
| 225 | + DataZoomComponent, |
| 226 | + LineChart, |
| 227 | + CanvasRenderer, |
| 228 | + UniversalTransition |
| 229 | +]); |
| 230 | +
|
| 231 | +
|
| 232 | +// 2.定义传入的参数 |
| 233 | +const props = defineProps({ |
| 234 | + width: { |
| 235 | + type: String, |
| 236 | + default: "550", |
| 237 | + }, |
| 238 | + height: { |
| 239 | + type: String, |
| 240 | + default: "350", |
| 241 | + }, |
| 242 | + //首次加载 |
| 243 | + isFirst: { |
| 244 | + type: Boolean, |
| 245 | + default: false, |
| 246 | + }, |
| 247 | + //组件唯一值 |
| 248 | + container: { |
| 249 | + type: String, |
| 250 | + default: "OSCChart", |
| 251 | + }, |
| 252 | +}); |
| 253 | +
|
| 254 | +
|
| 255 | +
|
| 256 | +onMounted(() => { |
| 257 | + chartDom = document.getElementById(props.container) as HTMLElement |
| 258 | + myChart = echarts.init(chartDom); |
| 259 | + option && myChart.setOption(option); |
| 260 | +}) |
| 261 | +
|
| 262 | +</script> |
| 263 | + |
| 264 | + |
262 | 265 | <style> |
263 | 266 | .OSChart { |
264 | 267 | margin: 0 auto; |
|
0 commit comments