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.
@@ -165,8 +165,10 @@ export const getOption = async (
165
165
  {
166
166
  type: 'inside',
167
167
  xAxisIndex: [0, 0],
168
- startValue: kLine.length >= defaultShowBarCount ? kLine.length - defaultShowBarCount : 0,
169
- endValue: kLine.length - 1,
168
+ start: kLine.length >= defaultShowBarCount ? (kLine.length - defaultShowBarCount) / kLine.length * 100 : 0,
169
+ end: 99.99
170
+ // startValue: kLine.length >= defaultShowBarCount ? kLine.length - defaultShowBarCount : 0,
171
+ // endValue: kLine.length - 1,
170
172
  },
171
173
  ],
172
174
  series: [
@@ -27,6 +27,7 @@ export interface InConfig {
27
27
  positionConfig: any // 持仓线配置
28
28
  conditionConfig: any // 条件单配置
29
29
  tipsConfig: any // Tips展示配置
30
+ dynamicLoadConfig: any // 动态加载历史/后续K线配置
30
31
  }
31
32
 
32
33
  //----------------额外画线数据相关TS类型---------------------
@@ -293,10 +293,10 @@ export const getConditionItem = (params: conditionParamsType) => {
293
293
  let handleKeyUp: any = null
294
294
  // [展示/隐藏]盈亏线
295
295
  const handleProfitLossShow = (groupItem: any, show: boolean) => {
296
- groupItem.children()[2].animate('style', false).when(200, { opacity: ~~show }).start()
297
- groupItem.children()[3].children()[0].animate('style', false).when(200, { opacity: ~~show }).start()
298
- groupItem.children()[4].animate('style', false).when(200, { opacity: ~~show }).start()
299
- groupItem.children()[5].children()[0].animate('style', false).when(200, { opacity: ~~show }).start()
296
+ groupItem.children()[2]?.animate('style', false).when(200, { opacity: ~~show }).start()
297
+ groupItem.children()[3].children()[0]?.animate('style', false).when(200, { opacity: ~~show }).start()
298
+ groupItem.children()[4]?.animate('style', false).when(200, { opacity: ~~show }).start()
299
+ groupItem.children()[5].children()[0]?.animate('style', false).when(200, { opacity: ~~show }).start()
300
300
  }
301
301
  // 默认的鼠标滑入事件
302
302
  const defaultOnMouseOver = (params: ElementEvent) => {
@@ -0,0 +1,8 @@
1
+ import { App } from "vue";
2
+ import StLinearLegend from "./index.vue";
3
+
4
+ export default {
5
+ install(app: App) {
6
+ app.component("st-linearLegend", StLinearLegend);
7
+ },
8
+ }
@@ -0,0 +1,269 @@
1
+ <template>
2
+ <div class="linearLegend">
3
+ <div class="linearLegend-unit" v-if="unit">(单位:{{ unit }})</div>
4
+ <div class="linearLegend-content">
5
+ <div class="linearLegend-content-box">
6
+ <div
7
+ class="linearLegend-content-box-item"
8
+ v-for="item in data"
9
+ :style="{
10
+ background: item.color
11
+ }"
12
+ ></div>
13
+ </div>
14
+ <div class="linearLegend-content-number">
15
+ <div
16
+ class="linearLegend-content-number-item"
17
+ v-for="item in numberData"
18
+ :style="{
19
+ width: `${item.width * 36}px`
20
+ }"
21
+ >{{ item.value }}</div>
22
+ </div>
23
+ </div>
24
+ </div>
25
+ </template>
26
+
27
+ <script setup lang="ts">
28
+ import { ref, computed } from "vue"
29
+
30
+ const props = defineProps({
31
+ data: {
32
+ type: Array,
33
+ default: () => ([]),
34
+ }, // 数据
35
+ unit: {
36
+ type: String,
37
+ default: () => null,
38
+ }, // 单位
39
+ })
40
+
41
+ const numberData = computed(() => {
42
+ return props.data.reduce((res, item, index) => {
43
+ if (index === props.data.length - 1) {
44
+ return res
45
+ }
46
+ if (item.type === '=') {
47
+ res[res.length - 1].width = 2
48
+ return res
49
+ } else if (item.range.length === 1) {
50
+ return [ ...res, { value: item.range[0], width: 1 } ]
51
+ } else {
52
+ return [ ...res, { value: item.range[1], width: 1 } ]
53
+ }
54
+ }, [])
55
+ })
56
+
57
+ defineExpose({
58
+ numberToColor: (number: number) => {
59
+ let multiplier = 1;
60
+ if (props.unit === '亿') {
61
+ multiplier = 100000000
62
+ } else if (props.unit === '万') {
63
+ multiplier = 10000
64
+ }
65
+ for(let i = 0; i < props.data.length; i++) {
66
+ const { type, color, range } = props.data[i]
67
+ if (
68
+ (type === '=' && number === range[0] * multiplier) ||
69
+ (type === '>' && number === range[0] * multiplier) ||
70
+ (type === '>=' && number === range[0] * multiplier) ||
71
+ (type === '<' && number === range[0] * multiplier) ||
72
+ (type === '<=' && number === range[0] * multiplier) ||
73
+ (type === '()' && number > range[0] * multiplier && number < range[1] * multiplier) ||
74
+ (type === '(]' && number > range[0] * multiplier && number <= range[1] * multiplier) ||
75
+ (type === '[]' && number >= range[0] * multiplier && number <= range[1] * multiplier) ||
76
+ (type === '[)' && number >= range[0] * multiplier && number < range[1] * multiplier)
77
+ ) {
78
+ return color
79
+ }
80
+ }
81
+ }, // 数值转颜色
82
+ })
83
+
84
+ const selectConfig = {
85
+ body: {
86
+ area: [
87
+ {
88
+ label: '总市值',
89
+ value: '对应id',
90
+ }
91
+ ],
92
+ color: [
93
+ {
94
+ label: '当前涨幅',
95
+ value: '对应id',
96
+ colorConfig: {
97
+ unit: '%',
98
+ range: [
99
+ {
100
+ range: [-7],
101
+ type: '<',
102
+ color: 'rgba(0, 128, 0, 0.4)',
103
+ },
104
+ {
105
+ range: [-7, -5],
106
+ type: '[)',
107
+ color: 'rgba(0, 128, 0, 0.6)',
108
+ },
109
+ {
110
+ range: [-5, -3],
111
+ type: '[)',
112
+ color: 'rgba(0, 128, 0, 0.8)',
113
+ },
114
+ {
115
+ range: [-3, 0],
116
+ type: '[)',
117
+ color: 'rgba(0, 128, 0, 1)',
118
+ },
119
+ {
120
+ range: [0],
121
+ type: '=',
122
+ color: '#000',
123
+ },
124
+ {
125
+ range: [0, 3],
126
+ type: '(]',
127
+ color: 'rgba(255, 0, 0, 1)',
128
+ },
129
+ {
130
+ range: [3, 5],
131
+ type: '(]',
132
+ color: 'rgba(255, 0, 0, 0.8)',
133
+ },
134
+ {
135
+ range: [5, 7],
136
+ type: '(]',
137
+ color: 'rgba(255, 0, 0, 0.6)',
138
+ },
139
+ {
140
+ range: [7],
141
+ type: '>',
142
+ color: 'rgba(255, 0, 0, 0.4)',
143
+ },
144
+ ]
145
+ }
146
+ },
147
+ {
148
+ label: '成交额',
149
+ value: '对应id',
150
+ colorConfig: {
151
+ unit: '亿',
152
+ range: [
153
+ {
154
+ range: [0.1],
155
+ type: '<=',
156
+ color: '#000',
157
+ },
158
+ {
159
+ range: [0.1, 0.2],
160
+ type: '(]',
161
+ color: '#000',
162
+ },
163
+ {
164
+ range: [0.2, 0.5],
165
+ type: '(]',
166
+ color: '#000',
167
+ },
168
+ {
169
+ range: [0.5, 1],
170
+ type: '(]',
171
+ color: '#000',
172
+ },
173
+ {
174
+ range: [1, 2],
175
+ type: '(]',
176
+ color: '#000',
177
+ },
178
+ {
179
+ range: [2, 5],
180
+ type: '(]',
181
+ color: '#000',
182
+ },
183
+ {
184
+ range: [5, 10],
185
+ type: '(]',
186
+ color: '#000',
187
+ },
188
+ {
189
+ range: [10, 20],
190
+ type: '(]',
191
+ color: '#000',
192
+ },
193
+ {
194
+ range: [20, 50],
195
+ type: '(]',
196
+ color: '#000',
197
+ },
198
+ {
199
+ range: [50],
200
+ type: '>',
201
+ color: '#000',
202
+ },
203
+ ]
204
+ }
205
+ }
206
+ ]
207
+ }
208
+ }
209
+
210
+ const res = {
211
+ body: [
212
+ {
213
+ name: '行业名称1',
214
+ value: '面积数值',
215
+ labelValue: '标题展示数据',
216
+ ['基础信息']: '基础信息',
217
+ children: [
218
+ {
219
+ name: '股票名称',
220
+ value: '面积数值',
221
+ ['基础信息']: '基础信息',
222
+ }
223
+ ], // 成分股
224
+ },
225
+ {
226
+ name: '行业名称2',
227
+ value: '面积数值',
228
+ labelValue: '标题展示数据',
229
+ ['基础信息']: '基础信息',
230
+ children: [
231
+ {
232
+ name: '股票名称',
233
+ value: '面积数值',
234
+ ['基础信息']: '基础信息',
235
+ }
236
+ ], // 成分股
237
+ },
238
+ ]
239
+ }
240
+ </script>
241
+
242
+ <style lang="scss" scoped>
243
+ .linearLegend {
244
+ display: inline-block;
245
+ &-unit {
246
+ display: inline-block;
247
+ vertical-align: top;
248
+ margin-right: 10px;
249
+ }
250
+ &-content {
251
+ display: inline-block;
252
+ &-box {
253
+ &-item {
254
+ display: inline-block;
255
+ width: 36px;
256
+ height: 12px;
257
+ }
258
+ }
259
+ &-number {
260
+ padding-left: 18px;
261
+ &-item {
262
+ display: inline-block;
263
+ text-align: center;
264
+ width: 36px;
265
+ }
266
+ }
267
+ }
268
+ }
269
+ </style>
@@ -6,7 +6,7 @@
6
6
  </template>
7
7
 
8
8
  <script setup lang="ts">
9
- import { ref, onMounted, onUnmounted, computed } from "vue"
9
+ import { ref, onMounted, onUnmounted, computed, watch } from "vue"
10
10
  import * as echarts from 'echarts'
11
11
  import ChinaJeoJson from './China.json'
12
12
  import type { EChartsType } from 'echarts'
@@ -15,6 +15,12 @@
15
15
  outOfRange: '#999', // 超出图例范围显示的颜色
16
16
  area: '#ddd', // 地图默认颜色
17
17
  areaLabel: '#000', // 地图label颜色
18
+ hoverArea: '#4791FF', // hover地图颜色
19
+ hoverAreaLabel: '#fff', // hover地图label颜色
20
+ legendColor: '#000', // 图例文字颜色
21
+ }
22
+ const defaultConfig = {
23
+ tooltipFormatter: null
18
24
  }
19
25
  let chart: EChartsType
20
26
  let resizeRo: any
@@ -27,21 +33,54 @@
27
33
  pieces: {
28
34
  type: Array,
29
35
  default: () => ([]),
30
- },
36
+ }, // 图例
37
+ config: {
38
+ type: Object,
39
+ default: () => ({})
40
+ }, // 配置
31
41
  style: {
32
42
  type: Object,
33
43
  default: () => ({})
34
- }
44
+ }, // 样式
35
45
  })
36
46
 
37
47
  const chartRef = ref<HTMLElement>()
38
48
 
39
49
  const mergeStyle = computed(() => ({ ...defaultStyle, ...props.style }))
50
+ const mergeConfig = computed(() => ({ ...defaultConfig, ...props.config }))
51
+
52
+ watch(
53
+ () => [props.data, props.pieces, props.style],
54
+ () => {
55
+ draw()
56
+ },
57
+ { deep: true }
58
+ )
40
59
 
41
60
  onMounted(() => {
42
- const { outOfRange, area } = mergeStyle.value
43
61
  chart = echarts.init(chartRef.value)
44
62
  echarts.registerMap('China', (ChinaJeoJson as any));
63
+ draw()
64
+ // 绑定resize事件
65
+ let isFirst: boolean | null = true
66
+ resizeRo = new ResizeObserver(() => {
67
+ if (isFirst) {
68
+ isFirst = null
69
+ return
70
+ }
71
+ chart.resize()
72
+ })
73
+ resizeRo.observe(chartRef.value)
74
+ })
75
+
76
+ onUnmounted(() => {
77
+ chart.dispose()
78
+ resizeRo.disconnect()
79
+ resizeRo = null
80
+ })
81
+
82
+ const draw = () => {
83
+ const { outOfRange, area, hoverArea, hoverAreaLabel, legendColor } = mergeStyle.value
45
84
  chart.setOption({
46
85
  visualMap: {
47
86
  pieces: props.pieces,
@@ -52,8 +91,14 @@
52
91
  itemHeight: 20,
53
92
  textStyle: {
54
93
  fontSize: 14,
94
+ color: legendColor,
55
95
  },
56
96
  },
97
+ tooltip: {
98
+ trigger: 'item',
99
+ confine: true,
100
+ formatter: mergeConfig.value.tooltipFormatter
101
+ },
57
102
  series: [
58
103
  {
59
104
  name: '中国地图',
@@ -74,7 +119,15 @@
74
119
  areaColor: area,
75
120
  },
76
121
  emphasis: {
77
- disabled: true,
122
+ itemStyle: {
123
+ areaColor: hoverArea,
124
+ shadowBlur: 10,
125
+ shadowOffsetX: 0,
126
+ shadowColor: 'rgba(32, 32, 32, 0.5)'
127
+ },
128
+ label: {
129
+ color: hoverAreaLabel,
130
+ }
78
131
  },
79
132
  select: {
80
133
  disabled: true,
@@ -83,23 +136,7 @@
83
136
  }
84
137
  ]
85
138
  })
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
- })
139
+ }
103
140
  </script>
104
141
 
105
142
  <style lang="scss" scoped>
@@ -6,14 +6,23 @@
6
6
  </template>
7
7
 
8
8
  <script setup lang="ts">
9
- import { ref, onMounted, onUnmounted, computed } from "vue"
9
+ import { ref, onMounted, onUnmounted, computed, watch } from "vue"
10
10
  import * as echarts from 'echarts'
11
11
  import type { EChartsType } from 'echarts'
12
12
  import { stMath } from 'st-func'
13
13
  const { add, multiply, divide, round } = stMath
14
14
 
15
15
  const defaultStyle = {
16
- colorList: ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc'], // 饼图颜色列表
16
+ colorList: [
17
+ '#FAF277', '#FFC467', '#FFA872', '#FB962E', '#FF772C', '#FF577C', '#F679D7', '#9B4A9B', '#9169D7', '#9192D0',
18
+ '#655AC7', '#4084DE', '#0074DA', '#0098DF', '#00BBE9', '#00D2DE', '#73E2E6', '#00CBB1', '#00B488', '#48D09A',
19
+ '#93D984', '#C9EC7C', '#D4E300', '#E2BA2B', '#A18300', '#BC6F3F', '#A84E12', '#7C462E', '#713532', '#962B23',
20
+ ], // 饼图颜色列表
21
+ legendColor: '#000',
22
+ inactiveColor: '#ccc',
23
+ }
24
+ const defaultConfig = {
25
+ tooltipFormatter: null
17
26
  }
18
27
  let chart: EChartsType
19
28
  let resizeRo: any
@@ -23,6 +32,10 @@
23
32
  type: Array,
24
33
  default: () => ([]),
25
34
  }, // 数据
35
+ config: {
36
+ type: Object,
37
+ default: () => ({})
38
+ }, // 配置
26
39
  style: {
27
40
  type: Object,
28
41
  default: () => ([])
@@ -32,16 +45,47 @@
32
45
  const chartRef = ref<HTMLElement>()
33
46
 
34
47
  const mergeStyle = computed(() => ({ ...defaultStyle, ...props.style }))
48
+ const mergeConfig = computed(() => ({ ...defaultConfig, ...props.config }))
49
+
50
+ watch(
51
+ () => [props.data, props.style],
52
+ () => {
53
+ draw()
54
+ },
55
+ { deep: true }
56
+ )
35
57
 
36
58
  onMounted(() => {
37
59
  chart = echarts.init(chartRef.value)
60
+ draw()
61
+ // 绑定resize事件
62
+ let isFirst: boolean | null = true
63
+ resizeRo = new ResizeObserver(() => {
64
+ if (isFirst) {
65
+ isFirst = null
66
+ return
67
+ }
68
+ chart.resize()
69
+ })
70
+ resizeRo.observe(chartRef.value)
71
+ })
72
+
73
+ onUnmounted(() => {
74
+ chart.dispose()
75
+ resizeRo.disconnect()
76
+ resizeRo = null
77
+ })
78
+
79
+ const draw = () => {
38
80
  const total: number = props.data.reduce((res: number, item: any) => {
39
81
  return add(res, item.value)
40
82
  }, 0)
41
83
  chart.setOption({
42
84
  color: mergeStyle.value.colorList,
43
85
  tooltip: {
44
- trigger: 'item'
86
+ trigger: 'item',
87
+ confine: true,
88
+ formatter: mergeConfig.value.tooltipFormatter
45
89
  },
46
90
  legend: {
47
91
  orient: 'vertical',
@@ -51,7 +95,9 @@
51
95
  itemHeight: 20,
52
96
  textStyle: {
53
97
  fontSize: 14,
98
+ color: mergeStyle.value.legendColor,
54
99
  },
100
+ inactiveColor: mergeStyle.value.inactiveColor,
55
101
  formatter: (name: string) => {
56
102
  const item: any = props.data.find((i: any) => i.name === name)
57
103
  return `${name}
@@ -60,15 +106,23 @@ ${item.value}(${round(multiply(divide(item.value, total), 100))}%)`
60
106
  },
61
107
  series: [
62
108
  {
63
- name: 'Access From',
64
109
  type: 'pie',
65
110
  width: '150%',
66
111
  height: '150%',
67
112
  center: [`${100/3}%`, `${100/3}%`],
68
113
  radius: '50%',
69
- data: props.data,
114
+ data: props.data.map((i: any) => ({
115
+ ...i,
116
+ itemStyle: {
117
+ color: i.color,
118
+ }
119
+ })),
70
120
  label: {
71
- show: false,
121
+ show: true,
122
+ position: 'inside',
123
+ formatter: (info: any) => info.value,
124
+ fontSize: 14,
125
+ color: '#000',
72
126
  },
73
127
  emphasis: {
74
128
  itemStyle: {
@@ -80,23 +134,7 @@ ${item.value}(${round(multiply(divide(item.value, total), 100))}%)`
80
134
  }
81
135
  ]
82
136
  })
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
- })
137
+ }
100
138
  </script>
101
139
 
102
140
  <style lang="scss" scoped>
@@ -0,0 +1,8 @@
1
+ import { App } from "vue";
2
+ import StTreeMap from "./index.vue";
3
+
4
+ export default {
5
+ install(app: App) {
6
+ app.component("st-treeMap", StTreeMap);
7
+ },
8
+ }