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.
@@ -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,32 @@
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
+ name: `title-${value}`,
24
+ value,
25
+ })
26
+ value = value - Math.ceil(Math.random() * 20)
27
+ }
28
+ </script>
29
+
30
+ <style lang="scss" scoped>
31
+
32
+ </style>