st-comp 0.0.20 → 0.0.21

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,8 @@
1
+ import { App } from "vue";
2
+ import StMap from "./index.vue";
3
+
4
+ export default {
5
+ install(app: App) {
6
+ app.component("st-map", StMap);
7
+ },
8
+ }
@@ -0,0 +1,110 @@
1
+ <template>
2
+ <div
3
+ ref="chartRef"
4
+ class="chart"
5
+ ></div>
6
+ </template>
7
+
8
+ <script setup lang="ts">
9
+ import { ref, onMounted, onUnmounted, computed } from "vue"
10
+ import * as echarts from 'echarts'
11
+ import ChinaJeoJson from './China.json'
12
+ import type { EChartsType } from 'echarts'
13
+
14
+ const defaultStyle = {
15
+ outOfRange: '#999', // 超出图例范围显示的颜色
16
+ area: '#ddd', // 地图默认颜色
17
+ areaLabel: '#000', // 地图label颜色
18
+ }
19
+ let chart: EChartsType
20
+ let resizeRo: any
21
+
22
+ const props = defineProps({
23
+ data: {
24
+ type: Array,
25
+ default: () => ([]),
26
+ }, // 数据
27
+ pieces: {
28
+ type: Array,
29
+ default: () => ([]),
30
+ },
31
+ style: {
32
+ type: Object,
33
+ default: () => ({})
34
+ }
35
+ })
36
+
37
+ const chartRef = ref<HTMLElement>()
38
+
39
+ const mergeStyle = computed(() => ({ ...defaultStyle, ...props.style }))
40
+
41
+ onMounted(() => {
42
+ const { outOfRange, area } = mergeStyle.value
43
+ chart = echarts.init(chartRef.value)
44
+ echarts.registerMap('China', (ChinaJeoJson as any));
45
+ chart.setOption({
46
+ visualMap: {
47
+ pieces: props.pieces,
48
+ outOfRange: {
49
+ color: outOfRange
50
+ },
51
+ itemWidth: 32,
52
+ itemHeight: 20,
53
+ textStyle: {
54
+ fontSize: 14,
55
+ },
56
+ },
57
+ series: [
58
+ {
59
+ name: '中国地图',
60
+ type: 'map',
61
+ map: 'China',
62
+ roam: true,
63
+ zoom: 1,
64
+ scaleLimit: {
65
+ min: 0.8,
66
+ max: 8,
67
+ },
68
+ layoutCenter: ['50%', '60%'],
69
+ layoutSize: '108%',
70
+ label: {
71
+ show: true
72
+ },
73
+ itemStyle: {
74
+ areaColor: area,
75
+ },
76
+ emphasis: {
77
+ disabled: true,
78
+ },
79
+ select: {
80
+ disabled: true,
81
+ },
82
+ data: props.data,
83
+ }
84
+ ]
85
+ })
86
+ // 绑定resize事件
87
+ let isFirst: boolean | null = true
88
+ resizeRo = new ResizeObserver(() => {
89
+ if (isFirst) {
90
+ isFirst = null
91
+ return
92
+ }
93
+ chart.resize()
94
+ })
95
+ resizeRo.observe(chartRef.value)
96
+ })
97
+
98
+ onUnmounted(() => {
99
+ chart.dispose()
100
+ resizeRo.disconnect()
101
+ resizeRo = null
102
+ })
103
+ </script>
104
+
105
+ <style lang="scss" scoped>
106
+ .chart {
107
+ width: 100%;
108
+ height: 100%;
109
+ }
110
+ </style>
@@ -0,0 +1,8 @@
1
+ import { App } from "vue";
2
+ import StPie from "./index.vue";
3
+
4
+ export default {
5
+ install(app: App) {
6
+ app.component("st-pie", StPie);
7
+ },
8
+ }
@@ -0,0 +1,107 @@
1
+ <template>
2
+ <div
3
+ ref="chartRef"
4
+ class="chart"
5
+ ></div>
6
+ </template>
7
+
8
+ <script setup lang="ts">
9
+ import { ref, onMounted, onUnmounted, computed } from "vue"
10
+ import * as echarts from 'echarts'
11
+ import type { EChartsType } from 'echarts'
12
+ import { stMath } from 'st-func'
13
+ const { add, multiply, divide, round } = stMath
14
+
15
+ const defaultStyle = {
16
+ colorList: ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc'], // 饼图颜色列表
17
+ }
18
+ let chart: EChartsType
19
+ let resizeRo: any
20
+
21
+ const props = defineProps({
22
+ data: {
23
+ type: Array,
24
+ default: () => ([]),
25
+ }, // 数据
26
+ style: {
27
+ type: Object,
28
+ default: () => ([])
29
+ }
30
+ })
31
+
32
+ const chartRef = ref<HTMLElement>()
33
+
34
+ const mergeStyle = computed(() => ({ ...defaultStyle, ...props.style }))
35
+
36
+ onMounted(() => {
37
+ chart = echarts.init(chartRef.value)
38
+ const total: number = props.data.reduce((res: number, item: any) => {
39
+ return add(res, item.value)
40
+ }, 0)
41
+ chart.setOption({
42
+ color: mergeStyle.value.colorList,
43
+ tooltip: {
44
+ trigger: 'item'
45
+ },
46
+ legend: {
47
+ orient: 'vertical',
48
+ right: 0,
49
+ bottom: 0,
50
+ itemWidth: 32,
51
+ itemHeight: 20,
52
+ textStyle: {
53
+ fontSize: 14,
54
+ },
55
+ formatter: (name: string) => {
56
+ const item: any = props.data.find((i: any) => i.name === name)
57
+ return `${name}
58
+ ${item.value}(${round(multiply(divide(item.value, total), 100))}%)`
59
+ }
60
+ },
61
+ series: [
62
+ {
63
+ name: 'Access From',
64
+ type: 'pie',
65
+ width: '150%',
66
+ height: '150%',
67
+ center: [`${100/3}%`, `${100/3}%`],
68
+ radius: '50%',
69
+ data: props.data,
70
+ label: {
71
+ show: false,
72
+ },
73
+ emphasis: {
74
+ itemStyle: {
75
+ shadowBlur: 10,
76
+ shadowOffsetX: 0,
77
+ shadowColor: 'rgba(0, 0, 0, 0.5)'
78
+ }
79
+ }
80
+ }
81
+ ]
82
+ })
83
+ // 绑定resize事件
84
+ let isFirst: boolean | null = true
85
+ resizeRo = new ResizeObserver(() => {
86
+ if (isFirst) {
87
+ isFirst = null
88
+ return
89
+ }
90
+ chart.resize()
91
+ })
92
+ resizeRo.observe(chartRef.value)
93
+ })
94
+
95
+ onUnmounted(() => {
96
+ chart.dispose()
97
+ resizeRo.disconnect()
98
+ resizeRo = null
99
+ })
100
+ </script>
101
+
102
+ <style lang="scss" scoped>
103
+ .chart {
104
+ width: 100%;
105
+ height: 100%;
106
+ }
107
+ </style>
package/packages/index.ts CHANGED
@@ -1,16 +1,22 @@
1
1
  import { App } from "vue"
2
2
  import StChartLayout from "./ChartLayout/index.ts"
3
3
  import StDialog from "./Dialog/index.ts"
4
+ import StHeatMap from "./HeatMap/index.ts"
4
5
  import StKline from "./Kline/index.ts"
6
+ import StMap from "./Map/index.ts"
5
7
  import StPagination from "./Pagination/index.ts"
8
+ import StPie from "./Pie/index.ts"
6
9
  import StTable from "./Table/index.ts"
7
10
 
8
11
  export default {
9
12
  install(app: App) {
10
13
  StChartLayout.install(app)
11
14
  StDialog.install(app)
15
+ StHeatMap.install(app)
12
16
  StKline.install(app)
17
+ StMap.install(app)
13
18
  StPagination.install(app)
19
+ StPie.install(app)
14
20
  StTable.install(app)
15
21
  },
16
22
  }
@@ -0,0 +1,286 @@
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
+ <template>
273
+ <div id="heatMap">
274
+ <div id="main"></div>
275
+ </div>
276
+ </template>
277
+
278
+ <style lang="scss" scoped>
279
+ #heatMap {
280
+ height: 100%;
281
+ #main {
282
+ width: 100%;
283
+ height: 100%;
284
+ }
285
+ }
286
+ </style>
@@ -68,6 +68,14 @@
68
68
  const config = ref({
69
69
  totalBarCount: 1900,
70
70
  preBarCount: 100,
71
+ tipsConfig: {
72
+ open: true,
73
+ heigh: true,
74
+ low: true,
75
+ close: true,
76
+ business: false,
77
+ riseAndFall: true
78
+ }
71
79
  })
72
80
 
73
81
  onMounted(() => {
@@ -0,0 +1,50 @@
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>
@@ -0,0 +1,19 @@
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>
@@ -9,16 +9,31 @@ export default [
9
9
  name: 'Dialog',
10
10
  component: () => import('../pages/Dialog/index.vue'),
11
11
  },
12
+ {
13
+ path: '/heatMap',
14
+ name: 'HeatMap',
15
+ component: () => import('../pages/HeatMap/index.vue'),
16
+ },
12
17
  {
13
18
  path: '/kline',
14
19
  name: 'Kline',
15
20
  component: () => import('../pages/Kline/index.vue'),
16
21
  },
22
+ {
23
+ path: '/map',
24
+ name: 'Map',
25
+ component: () => import('../pages/Map/index.vue'),
26
+ },
17
27
  {
18
28
  path: '/pagination',
19
29
  name: 'Pagination',
20
30
  component: () => import('../pages/Pagination/index.vue'),
21
31
  },
32
+ {
33
+ path: '/pie',
34
+ name: 'Pie',
35
+ component: () => import('../pages/Pie/index.vue'),
36
+ },
22
37
  {
23
38
  path: '/table',
24
39
  name: 'Table',
@@ -11,6 +11,9 @@ export default () => {
11
11
  return {
12
12
  name: 'createExport',
13
13
  buildStart() {
14
+ fs.unlink(`./packages/index.ts`, (err) => {
15
+ if (err) throw err
16
+ })
14
17
  fs.readdir('./packages', (err, files) => {
15
18
  if (err) {
16
19
  console.error(err)