st-comp 0.0.21 → 0.0.22

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,100 @@
1
- <!-- 热力图Demo页面 -->
2
- <script setup lang="ts">
3
- import * as echarts from "echarts";
4
- import { onMounted } from "vue";
5
-
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
- },
232
- },
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,
249
- },
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>
271
-
272
1
  <template>
273
- <div id="heatMap">
274
- <div id="main"></div>
2
+ <div style="height: 42px">
3
+ <st-linearLegend ref="linearLegendRef" :data="legendData" :unit="'亿'"/>
4
+ </div>
5
+ <div style="width: 100%;height: calc(100% - 42px);">
6
+ <st-heatMap ref="chartRef" :data="data" :config="config" />
275
7
  </div>
276
8
  </template>
277
9
 
278
- <style lang="scss" scoped>
279
- #heatMap {
280
- height: 100%;
281
- #main {
282
- width: 100%;
283
- height: 100%;
10
+ <script setup lang="ts">
11
+ import { ref, onMounted } from 'vue'
12
+
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
+ "2015-07-09 09:00:00",
45
+ "2015-07-10 09:00:00",
46
+ "2015-07-11 09:00:00",
47
+ "2015-07-12 09:00:00",
48
+ "2015-07-13 09:00:00",
49
+ "2015-07-14 09:00:00",
50
+ "2015-07-15 09:00:00",
51
+ "2015-07-16 09:00:00",
52
+ "2015-07-17 09:00:00",
53
+ "2015-07-18 09:00:00",
54
+ "2015-07-19 09:00:00",
55
+ "2015-07-20 09:00:00",
56
+ "2015-07-21 09:00:00",
57
+ "2015-07-22 09:00:00",
58
+ "2015-07-23 09:00:00",
59
+ "2015-07-24 09:00:00",
60
+ "2015-07-25 09:00:00",
61
+ "2015-07-26 09:00:00",
62
+ "2015-07-27 09:00:00",
63
+ "2015-07-28 09:00:00",
64
+ "2015-07-29 09:00:00",
65
+ "2015-07-30 09:00:00",
66
+ "2015-07-31 09:00:00",
67
+ "2015-08-01 09:00:00",
68
+ ]
69
+
70
+ const config = {
71
+
72
+ }
73
+
74
+ const data = ref<any>(null)
75
+
76
+ const init = () => {
77
+ data.value = {
78
+ date,
79
+ data: new Array(10).fill(null).map((item, index) => {
80
+ return {
81
+ name: `工商银行${index}`,
82
+ data: new Array(date.length).fill(null).map(i => {
83
+ const value = Math.random() * 1000000000
84
+ return {
85
+ value,
86
+ color: linearLegendRef.value.numberToColor(value)
87
+ }
88
+ })
89
+ }
90
+ })
284
91
  }
92
+ console.log(data.value)
285
93
  }
286
- </style>
94
+
95
+ onMounted(() => {
96
+ init()
97
+ })
98
+ </script>
99
+
100
+ <style lang="scss" scoped></style>
@@ -0,0 +1,92 @@
1
+ <template>
2
+ <div>
3
+ <st-linearLegend ref="linearLegendRef" :data="data" :unit="'%'"/>
4
+ </div>
5
+ <div>
6
+ <st-linearLegend :data="data2" :unit="'亿'"/>
7
+ </div>
8
+ </template>
9
+
10
+ <script setup lang="ts">
11
+ import { ref, onMounted } from 'vue'
12
+
13
+ const linearLegendRef = ref()
14
+
15
+ const data = [
16
+ {
17
+ range: [-7],
18
+ type: '<',
19
+ color: 'rgba(0, 128, 0, 0.4)',
20
+ },
21
+ {
22
+ range: [-7, -5],
23
+ type: '[)',
24
+ color: 'rgba(0, 128, 0, 0.6)',
25
+ },
26
+ {
27
+ range: [-5, -3],
28
+ type: '[)',
29
+ color: 'rgba(0, 128, 0, 0.8)',
30
+ },
31
+ {
32
+ range: [-3, 0],
33
+ type: '[)',
34
+ color: 'rgba(0, 128, 0, 1)',
35
+ },
36
+ {
37
+ range: [0],
38
+ type: '=',
39
+ color: '#000',
40
+ },
41
+ {
42
+ range: [0, 3],
43
+ type: '(]',
44
+ color: 'rgba(255, 0, 0, 1)',
45
+ },
46
+ {
47
+ range: [3, 5],
48
+ type: '(]',
49
+ color: 'rgba(255, 0, 0, 0.8)',
50
+ },
51
+ {
52
+ range: [5, 7],
53
+ type: '(]',
54
+ color: 'rgba(255, 0, 0, 0.6)',
55
+ },
56
+ {
57
+ range: [7],
58
+ type: '>',
59
+ color: 'rgba(255, 0, 0, 0.4)',
60
+ },
61
+ ]
62
+ const data2 = [
63
+ {
64
+ range: [0, 0.5],
65
+ type: '[)',
66
+ color: '#000',
67
+ },
68
+ {
69
+ range: [0.5, 1],
70
+ type: '[)',
71
+ color: 'rgba(255, 235, 59, 1)',
72
+ },
73
+ {
74
+ range: [1, 5],
75
+ type: '[)',
76
+ color: 'rgba(255, 235, 59, 0.6)',
77
+ },
78
+ {
79
+ range: [5, Infinity],
80
+ type: '>=',
81
+ color: 'rgba(255, 235, 59, 0.4)',
82
+ }
83
+ ]
84
+
85
+ onMounted(() => {
86
+ console.log(linearLegendRef.value.numberToColor(0))
87
+ })
88
+ </script>
89
+
90
+ <style lang="scss" scoped>
91
+
92
+ </style>
@@ -1,50 +1,62 @@
1
- <template>
2
- <div style="width: 100%;height: 100%;">
3
- <st-map
4
- :pieces="pieces"
5
- :data="data"
6
- />
7
- </div>
8
- </template>
9
-
10
- <script setup lang="ts">
11
- const pieces = [
12
- {
13
- gt: 0,
14
- lte: 50,
15
- color: '#93CE07'
16
- },
17
- {
18
- gt: 50,
19
- lte: 100,
20
- color: '#FBDB0F'
21
- },
22
- {
23
- gt: 100,
24
- lte: 150,
25
- color: '#FC7D02'
26
- },
27
- {
28
- gt: 150,
29
- lte: 200,
30
- color: '#FD0100'
31
- },
32
- {
33
- gt: 200,
34
- lte: 300,
35
- color: '#AA069F'
36
- },
37
- {
38
- gt: 300,
39
- color: '#AC3B2A'
40
- }
41
- ]
42
- const data = [
43
- { name: '黑龙江省', value: 20057.34 },
44
- { name: '浙江省', value: 15477.48 },
45
- ]
46
- </script>
47
-
48
- <style lang="scss" scoped>
49
-
50
- </style>
1
+ <template>
2
+ <div style="width: 100%;height: 100%;">
3
+ <st-map
4
+ :data="data"
5
+ :pieces="pieces"
6
+ :config="config"
7
+ />
8
+ </div>
9
+ </template>
10
+
11
+ <script setup lang="ts">
12
+ const config = {
13
+ tooltipFormatter: (params: any) => {
14
+ if (params.data) {
15
+ return `<div>
16
+ <div>${params.data.name} 18</div>
17
+ <div>中国石化 三一重工 中国联通 长江电力</div>
18
+ </div>`
19
+ }
20
+ return null
21
+ }
22
+ }
23
+ const pieces = [
24
+ {
25
+ gt: 0,
26
+ lte: 50,
27
+ color: '#93CE07'
28
+ },
29
+ {
30
+ gt: 50,
31
+ lte: 100,
32
+ color: '#FBDB0F'
33
+ },
34
+ {
35
+ gt: 100,
36
+ lte: 150,
37
+ color: '#FC7D02'
38
+ },
39
+ {
40
+ gt: 150,
41
+ lte: 200,
42
+ color: '#FD0100'
43
+ },
44
+ {
45
+ gt: 200,
46
+ lte: 300,
47
+ color: '#AA069F'
48
+ },
49
+ {
50
+ gt: 300,
51
+ color: '#AC3B2A'
52
+ }
53
+ ]
54
+ const data = [
55
+ { name: '黑龙江省', value: 20057.34 },
56
+ { name: '浙江省', value: 15477.48 },
57
+ ]
58
+ </script>
59
+
60
+ <style lang="scss" scoped>
61
+
62
+ </style>
@@ -1,19 +1,31 @@
1
- <template>
2
- <div style="width: 100%;height: 100%;">
3
- <st-pie :data="data" />
4
- </div>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- const data = [
9
- { value: 1048, name: 'Search Engine' },
10
- { value: 735, name: 'Direct' },
11
- { value: 580, name: 'Email' },
12
- { value: 484, name: 'Union Ads' },
13
- { value: 300, name: 'Video Ads' }
14
- ]
15
- </script>
16
-
17
- <style lang="scss" scoped>
18
-
19
- </style>
1
+ <template>
2
+ <div style="width: 100%;height: 100%;">
3
+ <st-pie :data="data" :config="config" />
4
+ </div>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ const config = {
9
+ tooltipFormatter: (params: any) => {
10
+ if (params.data) {
11
+ return `<div>
12
+ <div>${params.data.name} 18</div>
13
+ <div>中国石化 三一重工 中国联通 长江电力</div>
14
+ </div>`
15
+ }
16
+ return null
17
+ }
18
+ }
19
+ const data: any = []
20
+ let value: any = 300
21
+ while(value > 100) {
22
+ data.push({
23
+ value, name: `title-${value}`
24
+ })
25
+ value = value - Math.ceil(Math.random() * 20)
26
+ }
27
+ </script>
28
+
29
+ <style lang="scss" scoped>
30
+
31
+ </style>