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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
| <script lang="ts" setup>
| import type { EchartsUIType } from '@vben/plugins/echarts';
|
| import { onMounted, ref } from 'vue';
|
| import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
| import ecStat from 'echarts-stat';
|
| defineOptions({ name: 'ExtendGraphDemoEchartsScatter' });
|
| const chartRef = ref<EchartsUIType>();
| const { renderEcharts } = useEcharts(chartRef);
|
| const data = [
| [20, 60],
| [5, 11],
| [4, 19],
| [20, 80],
| [45, 90],
| [22, 34],
| [56, 78],
| [34, 66],
| [45, 90],
| [60, 89],
| [65, 120],
| [43, 87],
| [34, 65],
| [34, 45],
| [53, 87],
| [21, 39],
| [32, 76],
| [12, 54],
| [28, 73],
| [38, 87],
| [23, 24],
| [34, 65],
| [45, 43],
| [78, 100],
| [68, 72],
| [38, 70],
| [43, 72],
| [60, 93],
| [28, 58],
| [28, 54],
| [65, 98],
| [45, 80],
| [12, 30],
| [60, 94],
| [43, 63],
| [68, 102],
| [44, 89],
| [20, 48.32],
| [12, 38.78],
| [45, 78.49],
| [46.34, 88.49],
| [36.34, 65.49],
| [23.34, 43.34],
| [54.34, 98.34],
| [68.34, 106.49],
| [56.32, 91.34],
| [5.34, 31.49],
| [43.34, 74.34],
| [43.34, 76.49],
| [60.34, 99.49],
| [32.34, 65.49],
| [23.34, 54.79],
| [17.34, 43.49],
| [19.34, 45.49],
| [56.34, 88.49],
| [26.34, 65.49],
| [27.34, 85.49],
| [64.34, 110.49],
| [22, 45],
| ];
| const myRegression = ecStat.regression('linear', data, 1);
| myRegression.points.sort((a: any, b: any) => {
| return a[0] - b[0];
| });
|
| const options: any = {
| title: {
| text: '汽车速度与刹车距离',
| left: 'center',
| },
| tooltip: {
| trigger: 'axis',
| axisPointer: {
| type: 'cross',
| },
| },
| xAxis: {
| type: 'value',
| name: '汽车速度',
| splitLine: {
| lineStyle: {
| type: 'dashed',
| },
| },
| },
| yAxis: {
| type: 'value',
| name: '刹车距离',
| min: 1.5,
| splitLine: {
| lineStyle: {
| type: 'dashed',
| },
| },
| },
| series: [
| {
| name: 'scatter',
| type: 'scatter',
| emphasis: {
| label: {
| show: true,
| position: 'left',
| color: 'blue',
| fontSize: 16,
| },
| },
| data,
| },
| {
| name: 'line',
| type: 'line',
| showSymbol: false,
| data: myRegression.points,
| markPoint: {
| itemStyle: {
| color: 'transparent',
| },
| label: {
| show: true,
| position: 'left',
| formatter: myRegression.expression,
| color: '#333',
| fontSize: 14,
| },
| data: [
| {
| coord: myRegression.points[myRegression.points.length - 1],
| },
| ],
| },
| },
| ],
| };
|
| onMounted(() => {
| renderEcharts(options);
| });
| </script>
| <template>
| <div class="jnpf-content-wrapper">
| <div class="jnpf-content-wrapper-center bg-white px-[10px] pt-[40px]">
| <EchartsUI ref="chartRef" height="500px" />
| </div>
| </div>
| </template>
|
|