st-comp 0.0.21 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,286 +1,128 @@
1
- <!-- 热力图Demo页面 -->
1
+ <template>
2
+ <div style="height: 42px">
3
+ <st-linearLegend ref="linearLegendRef" :data="legendData" :unit="'亿'"/>
4
+ </div>
5
+ <div style="width: 100%;height: calc(100% - 42px);" v-if="data">
6
+ <st-heatMap ref="chartRef" :data="data" :config="config" />
7
+ </div>
8
+ </template>
9
+
2
10
  <script setup lang="ts">
3
- import * as echarts from "echarts";
4
- import { onMounted } from "vue";
11
+ import { ref, onMounted } from 'vue'
5
12
 
6
- onMounted(() => {
7
- const chartDom = document.getElementById("main");
8
- const myChart = echarts.init(chartDom);
9
- const xAxisData = [
10
- "2015-07-09 09:00:00",
11
- "2015-07-10 09:00:00",
12
- "2015-07-11 09:00:00",
13
- "2015-07-12 09:00:00",
14
- "2015-07-13 09:00:00",
15
- "2015-07-14 09:00:00",
16
- "2015-07-15 09:00:00",
17
- "2015-07-16 09:00:00",
18
- "2015-07-17 09:00:00",
19
- "2015-07-18 09:00:00",
20
- "2015-07-19 09:00:00",
21
- "2015-07-20 09:00:00",
22
- "2015-07-21 09:00:00",
23
- "2015-07-22 09:00:00",
24
- "2015-07-23 09:00:00",
25
- "2015-07-24 09:00:00",
26
- "2015-07-25 09:00:00",
27
- "2015-07-26 09:00:00",
28
- "2015-07-27 09:00:00",
29
- "2015-07-28 09:00:00",
30
- "2015-07-29 09:00:00",
31
- "2015-07-30 09:00:00",
32
- "2015-07-31 09:00:00",
33
- "2015-08-01 09:00:00",
34
- ];
35
- const yAxisData = ["平安银行", "万科A", "国华网安", "ST星源", "中国宝安", "神州数码", "华联控股"];
36
- const seriesData = [
37
- [0, 0, 5],
38
- [0, 1, 1],
39
- [0, 2, 0],
40
- [0, 3, 0],
41
- [0, 4, 0],
42
- [0, 5, 0],
43
- [0, 6, 0],
44
- [0, 7, 0],
45
- [0, 8, 0],
46
- [0, 9, 0],
47
- [0, 10, 0],
48
- [0, 11, 2],
49
- [0, 12, 4],
50
- [0, 13, 1],
51
- [0, 14, 1],
52
- [0, 15, 3],
53
- [0, 16, 4],
54
- [0, 17, 6],
55
- [0, 18, 4],
56
- [0, 19, 4],
57
- [0, 20, 3],
58
- [0, 21, 3],
59
- [0, 22, 2],
60
- [0, 23, 5],
61
- [1, 0, 7],
62
- [1, 1, 0],
63
- [1, 2, 0],
64
- [1, 3, 0],
65
- [1, 4, 0],
66
- [1, 5, 0],
67
- [1, 6, 0],
68
- [1, 7, 0],
69
- [1, 8, 0],
70
- [1, 9, 0],
71
- [1, 10, 5],
72
- [1, 11, 2],
73
- [1, 12, 2],
74
- [1, 13, 6],
75
- [1, 14, 9],
76
- [1, 15, 11],
77
- [1, 16, 6],
78
- [1, 17, 7],
79
- [1, 18, 8],
80
- [1, 19, 12],
81
- [1, 20, 5],
82
- [1, 21, 5],
83
- [1, 22, 7],
84
- [1, 23, 2],
85
- [2, 0, 1],
86
- [2, 1, 1],
87
- [2, 2, 0],
88
- [2, 3, 0],
89
- [2, 4, 0],
90
- [2, 5, 0],
91
- [2, 6, 0],
92
- [2, 7, 0],
93
- [2, 8, 0],
94
- [2, 9, 0],
95
- [2, 10, 3],
96
- [2, 11, 2],
97
- [2, 12, 1],
98
- [2, 13, 9],
99
- [2, 14, 8],
100
- [2, 15, 10],
101
- [2, 16, 6],
102
- [2, 17, 5],
103
- [2, 18, 5],
104
- [2, 19, 5],
105
- [2, 20, 7],
106
- [2, 21, 4],
107
- [2, 22, 2],
108
- [2, 23, 4],
109
- [3, 0, 7],
110
- [3, 1, 3],
111
- [3, 2, 0],
112
- [3, 3, 0],
113
- [3, 4, 0],
114
- [3, 5, 0],
115
- [3, 6, 0],
116
- [3, 7, 0],
117
- [3, 8, 1],
118
- [3, 9, 0],
119
- [3, 10, 5],
120
- [3, 11, 4],
121
- [3, 12, 7],
122
- [3, 13, 14],
123
- [3, 14, 13],
124
- [3, 15, 12],
125
- [3, 16, 9],
126
- [3, 17, 5],
127
- [3, 18, 5],
128
- [3, 19, 10],
129
- [3, 20, 6],
130
- [3, 21, 4],
131
- [3, 22, 4],
132
- [3, 23, 1],
133
- [4, 0, 1],
134
- [4, 1, 3],
135
- [4, 2, 0],
136
- [4, 3, 0],
137
- [4, 4, 0],
138
- [4, 5, 1],
139
- [4, 6, 0],
140
- [4, 7, 0],
141
- [4, 8, 0],
142
- [4, 9, 2],
143
- [4, 10, 4],
144
- [4, 11, 4],
145
- [4, 12, 2],
146
- [4, 13, 4],
147
- [4, 14, 4],
148
- [4, 15, 14],
149
- [4, 16, 12],
150
- [4, 17, 1],
151
- [4, 18, 8],
152
- [4, 19, 5],
153
- [4, 20, 3],
154
- [4, 21, 7],
155
- [4, 22, 3],
156
- [4, 23, 0],
157
- [5, 0, 2],
158
- [5, 1, 1],
159
- [5, 2, 0],
160
- [5, 3, 3],
161
- [5, 4, 0],
162
- [5, 5, 0],
163
- [5, 6, 0],
164
- [5, 7, 0],
165
- [5, 8, 2],
166
- [5, 9, 0],
167
- [5, 10, 4],
168
- [5, 11, 1],
169
- [5, 12, 5],
170
- [5, 13, 10],
171
- [5, 14, 5],
172
- [5, 15, 7],
173
- [5, 16, 11],
174
- [5, 17, 6],
175
- [5, 18, 0],
176
- [5, 19, 5],
177
- [5, 20, 3],
178
- [5, 21, 4],
179
- [5, 22, 2],
180
- [5, 23, 0],
181
- [6, 0, 1],
182
- [6, 1, 0],
183
- [6, 2, 0],
184
- [6, 3, 0],
185
- [6, 4, 0],
186
- [6, 5, 0],
187
- [6, 6, 0],
188
- [6, 7, 0],
189
- [6, 8, 0],
190
- [6, 9, 0],
191
- [6, 10, 1],
192
- [6, 11, 0],
193
- [6, 12, 2],
194
- [6, 13, 1],
195
- [6, 14, 3],
196
- [6, 15, 4],
197
- [6, 16, 0],
198
- [6, 17, 0],
199
- [6, 18, 0],
200
- [6, 19, 0],
201
- [6, 20, 1],
202
- [6, 21, 2],
203
- [6, 22, 2],
204
- [6, 23, 6],
205
- ].map(function (item) {
206
- // 三维数组[X轴位置,Y轴位置,值]
207
- return [item[1], item[0], item[2] || "-"];
208
- });
209
- const option = {
210
- tooltip: {
211
- position: "top",
212
- },
213
- grid: {
214
- left: '60px',
215
- bottom: '20px',
216
- right: 0,
217
- top: '40px'
218
- },
219
- xAxis: {
220
- type: "category",
221
- data: xAxisData,
222
- splitArea: {
223
- show: true,
224
- },
225
- },
226
- yAxis: {
227
- type: "category",
228
- data: yAxisData,
229
- splitArea: {
230
- show: true,
231
- },
13
+ const linearLegendRef = ref()
14
+
15
+ const legendData = [
16
+ {
17
+ range: [0, 0.5],
18
+ type: '[)',
19
+ color: '#999',
20
+ },
21
+ {
22
+ range: [0.5, 1],
23
+ type: '[)',
24
+ color: 'rgba(255, 235, 59, 0.4)',
25
+ },
26
+ {
27
+ range: [1, 5],
28
+ type: '[)',
29
+ color: 'rgba(255, 235, 59, 0.6)',
30
+ },
31
+ {
32
+ range: [5, 10],
33
+ type: '[)',
34
+ color: 'rgba(255, 235, 59, 0.8)',
35
+ },
36
+ {
37
+ range: [10],
38
+ type: '>=',
39
+ color: 'rgba(255, 235, 59, 1)',
40
+ },
41
+ ]
42
+
43
+ const date = [
44
+ "2024-02-01",
45
+ "2024-02-02",
46
+ "",
47
+ "2024-02-05",
48
+ "2024-02-06",
49
+ "2024-02-07",
50
+ "2024-02-08",
51
+ "2024-02-09",
52
+ "",
53
+ "2024-02-12",
54
+ "2024-02-13",
55
+ "2024-02-14",
56
+ "2024-02-15",
57
+ "2024-02-16",
58
+ "",
59
+ "2024-02-19",
60
+ "2024-02-20",
61
+ "2024-02-21",
62
+ "2024-02-22",
63
+ "2024-02-23",
64
+ "",
65
+ "2024-02-26",
66
+ "2024-02-27",
67
+ "2024-02-28",
68
+ "2024-02-29",
69
+ ]
70
+
71
+ const config = {
72
+ tooltipFormatter: (info: any) => {
73
+ return `<div>
74
+ <div>${data.value.data[info.data.value[1]].name}</div>
75
+ <div>日期:${data.value.date[info.data.value[0]]}</div>
76
+ <div>成交额:${info.data.value[2]}</div>
77
+ </div>`
78
+ },
79
+ grid: {
80
+ left: '60px',
81
+ bottom: '20px',
82
+ right: '50px',
83
+ top: 0
84
+ },
85
+ dataZoom: [
86
+ {
87
+ show: true,
88
+ realtime: true,
89
+ yAxisIndex: [0, 1],
90
+ startValue: 0,
91
+ endValue: 20,
232
92
  },
233
- visualMap: {
234
- type: 'piecewise', // 类型: 分段式[piecewise] | 连续形[continuous]
235
- min: 1, // 最小值
236
- max: 5, // 最大值
237
- calculable: true, // 是否显示拖拽用的手柄
238
- orient: "horizontal", // 放置visualMap组件: 水平[horizontal] | 垂直[vertical]
239
- pieces: [
240
- {value:1,label:'-1颜色',color:'#00ff99'},
241
- {value:2,label:'-2颜色',color:'#33cc33'},
242
- {value:3,label:'-3颜色',color:'#520101'},
243
- {value:4,label:'-4颜色',color:'#8b011c'},
244
- {value:5,label:'-5颜色',color:'#ff0000'},
245
- ],
246
- // inRange: ['#00ff99','#33cc33','#520101','#8b011c','#ff0000'],
247
- top:0,
248
- right: 0,
93
+ {
94
+ type: 'inside',
95
+ yAxisIndex: [0, 0],
249
96
  },
250
- series: [
251
- {
252
- name: "热力图",
253
- type: "heatmap",
254
- data: seriesData,
255
- label: {
256
- show: false, // 是否展示方块格上的数字
257
- },
258
- // 高亮状态的图形样式
259
- emphasis: {
260
- itemStyle: {
261
- shadowBlur: 10,
262
- shadowColor: "rgba(0, 0, 0, 0.5)",
263
- },
264
- },
265
- },
266
- ],
267
- };
268
- option && myChart.setOption(option);
269
- });
270
- </script>
97
+ ],
98
+ }
271
99
 
272
- <template>
273
- <div id="heatMap">
274
- <div id="main"></div>
275
- </div>
276
- </template>
100
+ const data = ref<any>(null)
277
101
 
278
- <style lang="scss" scoped>
279
- #heatMap {
280
- height: 100%;
281
- #main {
282
- width: 100%;
283
- height: 100%;
102
+ const init = () => {
103
+ data.value = {
104
+ date,
105
+ data: new Array(50).fill(null).map((item, index) => {
106
+ return {
107
+ name: `工商银行${index}`,
108
+ data: date.map((i) => {
109
+ if (i === '') {
110
+ return null
111
+ }
112
+ const value = Math.random() * 1000000000
113
+ return {
114
+ value,
115
+ color: linearLegendRef.value.numberToColor(value)
116
+ }
117
+ })
118
+ }
119
+ })
284
120
  }
285
121
  }
286
- </style>
122
+
123
+ onMounted(() => {
124
+ init()
125
+ })
126
+ </script>
127
+
128
+ <style lang="scss" scoped></style>