1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
| <template>
| <mars-pannel :visible="true" right="10" top="10">
| <div id="section" style="width: 500px; height: 200px"></div>
| </mars-pannel>
| </template>
|
| <script setup lang="ts">
| import * as echarts from "echarts"
| import * as mapWork from "./map.js"
|
| mapWork.echartTarget.on("addEchart", function (event: any) {
| drawHeightToDistanceEcharts(event.heightArry, event.heightTDArray, event.distanceArray)
| })
|
| // 获取的dom元素
| function drawHeightToDistanceEcharts(heightArry: any[], heightTDArray: any[], distanceArray: any[]) {
| const myChart = echarts.init(document.getElementById("section")!, "dark")
|
| const option = {
| title: {
| text: "断面图",
| left: 25
| },
| tooltip: {
| trigger: "axis",
| axisPointer: {
| type: "cross"
| }
| },
| toolbox: {
| show: false,
| feature: {
| saveAsImage: {}
| }
| },
| legend: {
| data: ["地形高程", "电线高程"]
| },
| grid: {
| left: 50,
| width: 425,
| top: 50,
| bottom: 30
| },
| xAxis: {
| type: "category",
| boundaryGap: false,
| data: distanceArray
| },
| yAxis: {
| type: "value",
| axisLabel: {
| formatter: "{value} 米"
| },
| axisPointer: {
| snap: true
| }
| },
| dataZoom: {
| start: 80,
| type: "inside"
| },
| series: [
| {
| name: "地形高程",
| type: "line",
| smooth: true,
| itemStyle: {
| normal: {
| color: "rgb(255, 255, 0)"
| }
| },
| data: heightTDArray
| },
| {
| name: "电线高程",
| type: "line",
| smooth: true,
| itemStyle: {
| normal: {
| color: "rgb(255, 70, 131)"
| }
| },
| data: heightArry
| }
| ]
| }
| myChart.setOption(option, true)
| }
| </script>
|
|