st-comp 0.0.30 → 0.0.32
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.
- package/lib/bundle.js +6524 -6487
- package/lib/bundle.umd.cjs +37 -37
- package/lib/style.css +1 -1
- package/package.json +1 -1
- package/packages/Kline/index.vue +1 -6
- package/packages/Kline/option.ts +133 -106
- package/packages/Kline/utils.ts +261 -223
- package/src/pages/Kline/api.ts +15 -1
- package/src/pages/Kline/components/SingleCycleSingleVariety.vue +206 -88
- package/src/pages/TreeMap/index.vue +3 -2
- package/vite.config.ts +0 -5
package/package.json
CHANGED
package/packages/Kline/index.vue
CHANGED
|
@@ -112,7 +112,6 @@ const defaultConfig: InConfig = {
|
|
|
112
112
|
close: true,
|
|
113
113
|
business: true,
|
|
114
114
|
riseAndFall: true,
|
|
115
|
-
netPosition: false,
|
|
116
115
|
},
|
|
117
116
|
// 动态加载配置
|
|
118
117
|
dynamicLoadConfig: {
|
|
@@ -141,7 +140,7 @@ const kLineTips = computed(() => {
|
|
|
141
140
|
const klineItem = option.value.dataset[0].source.klineData[activeIndex.value];
|
|
142
141
|
// 处理结果
|
|
143
142
|
const result = [];
|
|
144
|
-
const { open, heigh, low, close, business, riseAndFall
|
|
143
|
+
const { open, heigh, low, close, business, riseAndFall } = config.value.tipsConfig;
|
|
145
144
|
open && result.push({ label: "开", value: formatValue(klineItem[0]), color: "rgb(153, 153, 153)" });
|
|
146
145
|
heigh && result.push({ label: "高", value: formatValue(klineItem[3]), color: "rgb(153, 153, 153)" });
|
|
147
146
|
low && result.push({ label: "低", value: formatValue(klineItem[2]), color: "rgb(153, 153, 153)" });
|
|
@@ -152,10 +151,6 @@ const kLineTips = computed(() => {
|
|
|
152
151
|
let ratioColor = +ratio === 0.0 ? "white" : +ratio > 0 ? "red" : "#00ff00";
|
|
153
152
|
result.push({ label: "涨跌", value: `${ratio}%`, color: ratioColor });
|
|
154
153
|
}
|
|
155
|
-
if (netPosition) {
|
|
156
|
-
const value = props.netPositionData[activeIndex.value] ? formatPrice(props.netPositionData[activeIndex.value] as number) : null
|
|
157
|
-
value!== null && result.push({ label: "资产持仓净值", value, color: "rgb(153, 153, 153)" });
|
|
158
|
-
}
|
|
159
154
|
return result;
|
|
160
155
|
}
|
|
161
156
|
return [];
|
package/packages/Kline/option.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import formatKlineData from
|
|
2
|
-
import type { EChartsType } from
|
|
1
|
+
import formatKlineData from "./formatKlineData";
|
|
2
|
+
import type { EChartsType } from "echarts";
|
|
3
3
|
import type {
|
|
4
4
|
KlineDataType,
|
|
5
5
|
IndicatorConfigType,
|
|
@@ -9,8 +9,8 @@ import type {
|
|
|
9
9
|
PositionDataItem,
|
|
10
10
|
ConditionDataItem,
|
|
11
11
|
GraphicEvent,
|
|
12
|
-
} from
|
|
13
|
-
import { formatValue, getWarningItem, getPositionItem, getConditionItem, handlePoint } from
|
|
12
|
+
} from "./type.d.ts";
|
|
13
|
+
import { formatValue, getWarningItem, getPositionItem, getConditionItem, handlePoint } from "./utils";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* @description: 格式化K线图配置项
|
|
@@ -28,7 +28,7 @@ export const getOption = async (
|
|
|
28
28
|
config: InConfig,
|
|
29
29
|
netPositionData: any
|
|
30
30
|
) => {
|
|
31
|
-
const { totalBarCount, defaultShowBarCount, gridLeft, gridTop, gridRight, gridBottom, zoomLock } = config
|
|
31
|
+
const { totalBarCount, defaultShowBarCount, gridLeft, gridTop, gridRight, gridBottom, zoomLock } = config;
|
|
32
32
|
/**
|
|
33
33
|
* @todo: 1.数据处理
|
|
34
34
|
* @returns {Array<'YYYY-MM-DD HH:mm:ss'>} time 用于X轴的时间数组
|
|
@@ -36,17 +36,17 @@ export const getOption = async (
|
|
|
36
36
|
* @returns {Array<{时间,开,高,低,收,成交量,成交额}>} originData 源数据K线
|
|
37
37
|
* @returns {Array<{key:'DKX',color:'#FFFFFF',data:[开]}>} indicator 用于渲染line[指标线]
|
|
38
38
|
*/
|
|
39
|
-
const { time, kLine, originData, indicator } = await formatKlineData(klineData, indicatorConfig, totalBarCount)
|
|
39
|
+
const { time, kLine, originData, indicator } = await formatKlineData(klineData, indicatorConfig, totalBarCount);
|
|
40
40
|
/**
|
|
41
41
|
* @todo: 2.指标线渲染项处理
|
|
42
42
|
*/
|
|
43
|
-
const lineSeries = indicator.map(item => {
|
|
44
|
-
const { key, data, color } = item
|
|
43
|
+
const lineSeries = indicator.map((item) => {
|
|
44
|
+
const { key, data, color } = item;
|
|
45
45
|
return {
|
|
46
46
|
name: key,
|
|
47
|
-
type:
|
|
47
|
+
type: "line",
|
|
48
48
|
silent: true,
|
|
49
|
-
symbol:
|
|
49
|
+
symbol: "none",
|
|
50
50
|
data,
|
|
51
51
|
lineStyle: {
|
|
52
52
|
width: 1,
|
|
@@ -54,24 +54,33 @@ export const getOption = async (
|
|
|
54
54
|
itemStyle: {
|
|
55
55
|
color,
|
|
56
56
|
},
|
|
57
|
-
}
|
|
58
|
-
})
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
59
|
/**
|
|
60
60
|
* @todo: 3.标注点位渲染项处理
|
|
61
61
|
*/
|
|
62
|
-
const markPointData = handlePoint(markData, originData)
|
|
62
|
+
const markPointData = handlePoint(markData, originData);
|
|
63
63
|
const timePointData = markData.reduce((result, next) => {
|
|
64
|
-
const { data } = next
|
|
64
|
+
const { data } = next;
|
|
65
65
|
// 无数据直接循环下一组数据
|
|
66
|
-
if (data === null || data.length === 0) return result
|
|
67
|
-
result.push(...data)
|
|
68
|
-
return result
|
|
69
|
-
}, [])
|
|
66
|
+
if (data === null || data.length === 0) return result;
|
|
67
|
+
result.push(...data);
|
|
68
|
+
return result;
|
|
69
|
+
}, []);
|
|
70
|
+
/**
|
|
71
|
+
* @todo: 4.标注点位连线渲染处理
|
|
72
|
+
*/
|
|
73
|
+
let markLineData = []
|
|
74
|
+
markPointData.forEach(item => {
|
|
75
|
+
if (item.markLineTarget) {
|
|
76
|
+
markLineData = [...markLineData, ...item.markLineTarget]
|
|
77
|
+
}
|
|
78
|
+
})
|
|
70
79
|
// -----return------
|
|
71
80
|
return {
|
|
72
81
|
animation: false,
|
|
73
82
|
dataset: {
|
|
74
|
-
id:
|
|
83
|
+
id: "data",
|
|
75
84
|
source: {
|
|
76
85
|
klineData: kLine,
|
|
77
86
|
indicatorData: indicator,
|
|
@@ -84,38 +93,45 @@ export const getOption = async (
|
|
|
84
93
|
bottom: `${gridBottom}px`,
|
|
85
94
|
},
|
|
86
95
|
tooltip: {
|
|
87
|
-
trigger:
|
|
96
|
+
trigger: "axis",
|
|
88
97
|
axisPointer: {
|
|
89
|
-
type:
|
|
98
|
+
type: "cross",
|
|
90
99
|
label: {
|
|
91
100
|
formatter: (data: any) => {
|
|
92
|
-
const { axisDimension, value } = data
|
|
93
|
-
if (axisDimension ===
|
|
94
|
-
return value
|
|
101
|
+
const { axisDimension, value } = data;
|
|
102
|
+
if (axisDimension === "x") {
|
|
103
|
+
return value;
|
|
95
104
|
} else {
|
|
96
|
-
return String(formatValue(value))
|
|
105
|
+
return String(formatValue(value));
|
|
97
106
|
}
|
|
98
107
|
},
|
|
99
108
|
},
|
|
100
109
|
},
|
|
101
|
-
formatter: params => {
|
|
102
|
-
let html: null | string = null
|
|
103
|
-
let body: string =
|
|
104
|
-
params.forEach(item => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
})
|
|
110
|
-
if (item.componentSubType === 'candlestick' && body) {
|
|
111
|
-
html = `<div><span style="font-weight: bold;">${item.axisValue}</span>${body}</div>`
|
|
110
|
+
formatter: (params) => {
|
|
111
|
+
let html: null | string = null;
|
|
112
|
+
let body: string = "";
|
|
113
|
+
params.forEach((item) => {
|
|
114
|
+
// 资产持仓净值tooltip渲染逻辑
|
|
115
|
+
if (item.seriesName === "资产持仓净值" && item.data !== null) {
|
|
116
|
+
body += `<div>资产持仓净值: ${item.data}</div>`;
|
|
112
117
|
}
|
|
113
|
-
|
|
114
|
-
|
|
118
|
+
if (item.componentSubType === "candlestick") {
|
|
119
|
+
// 买卖点tooltip渲染逻辑
|
|
120
|
+
timePointData.forEach((i) => {
|
|
121
|
+
if (i.time === item.axisValue) {
|
|
122
|
+
body += i.tooltip;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
if (body) {
|
|
127
|
+
html = `<div><span style="font-weight: bold;">${item.axisValue}</span>${body}</div>`;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
return html;
|
|
115
131
|
},
|
|
116
132
|
},
|
|
117
133
|
xAxis: {
|
|
118
|
-
type:
|
|
134
|
+
type: "category",
|
|
119
135
|
data: time,
|
|
120
136
|
axisLine: {
|
|
121
137
|
show: true,
|
|
@@ -123,8 +139,8 @@ export const getOption = async (
|
|
|
123
139
|
splitLine: {
|
|
124
140
|
show: true,
|
|
125
141
|
lineStyle: {
|
|
126
|
-
type:
|
|
127
|
-
color:
|
|
142
|
+
type: "dotted",
|
|
143
|
+
color: "#333",
|
|
128
144
|
},
|
|
129
145
|
},
|
|
130
146
|
axisLabel: {
|
|
@@ -138,19 +154,19 @@ export const getOption = async (
|
|
|
138
154
|
splitLine: {
|
|
139
155
|
show: true,
|
|
140
156
|
lineStyle: {
|
|
141
|
-
type:
|
|
142
|
-
color:
|
|
157
|
+
type: "dotted",
|
|
158
|
+
color: "#333",
|
|
143
159
|
},
|
|
144
160
|
},
|
|
145
161
|
min: (value: any) => {
|
|
146
|
-
const { min, max } = value
|
|
147
|
-
const interval = Math.abs((max - min) / 10)
|
|
148
|
-
return min - interval
|
|
162
|
+
const { min, max } = value;
|
|
163
|
+
const interval = Math.abs((max - min) / 10);
|
|
164
|
+
return min - interval;
|
|
149
165
|
},
|
|
150
166
|
max: (value: any) => {
|
|
151
|
-
const { min, max } = value
|
|
152
|
-
const interval = Math.abs((max - min) / 10)
|
|
153
|
-
return max + interval
|
|
167
|
+
const { min, max } = value;
|
|
168
|
+
const interval = Math.abs((max - min) / 10);
|
|
169
|
+
return max + interval;
|
|
154
170
|
},
|
|
155
171
|
axisLine: {
|
|
156
172
|
show: true,
|
|
@@ -160,35 +176,46 @@ export const getOption = async (
|
|
|
160
176
|
showMaxLabel: false,
|
|
161
177
|
},
|
|
162
178
|
},
|
|
163
|
-
{
|
|
179
|
+
{
|
|
164
180
|
show: false,
|
|
165
|
-
min:
|
|
166
|
-
}
|
|
181
|
+
min: "dataMin",
|
|
182
|
+
},
|
|
167
183
|
],
|
|
168
184
|
dataZoom: [
|
|
169
185
|
{
|
|
170
|
-
type:
|
|
186
|
+
type: "inside",
|
|
171
187
|
xAxisIndex: [0, 0],
|
|
172
188
|
zoomLock,
|
|
173
|
-
start: kLine.length >= defaultShowBarCount ? (kLine.length - defaultShowBarCount) / kLine.length * 100 : 0,
|
|
174
|
-
end: 99.99
|
|
189
|
+
start: kLine.length >= defaultShowBarCount ? ((kLine.length - defaultShowBarCount) / kLine.length) * 100 : 0,
|
|
190
|
+
end: 99.99,
|
|
175
191
|
// startValue: kLine.length >= defaultShowBarCount ? kLine.length - defaultShowBarCount : 0,
|
|
176
192
|
// endValue: kLine.length - 1,
|
|
177
193
|
},
|
|
178
194
|
],
|
|
179
195
|
series: [
|
|
180
196
|
{
|
|
181
|
-
name:
|
|
182
|
-
type:
|
|
197
|
+
name: "k线",
|
|
198
|
+
type: "candlestick",
|
|
183
199
|
data: kLine,
|
|
184
200
|
markPoint: {
|
|
185
201
|
data: markPointData,
|
|
186
202
|
},
|
|
203
|
+
markLine: {
|
|
204
|
+
position: "middle",
|
|
205
|
+
textStyle: { color: "blue", fontSize: 15 },
|
|
206
|
+
animation: false,
|
|
207
|
+
data: markLineData,
|
|
208
|
+
lineStyle: {
|
|
209
|
+
width: 3,
|
|
210
|
+
type: "solid",
|
|
211
|
+
},
|
|
212
|
+
symbol: ["none", "none"],
|
|
213
|
+
},
|
|
187
214
|
itemStyle: {
|
|
188
|
-
color:
|
|
189
|
-
color0:
|
|
190
|
-
borderColor:
|
|
191
|
-
borderColor0:
|
|
215
|
+
color: "transparent",
|
|
216
|
+
color0: "#00FFFF",
|
|
217
|
+
borderColor: "#FF0000",
|
|
218
|
+
borderColor0: "#00FFFF",
|
|
192
219
|
borderWidth: 1,
|
|
193
220
|
},
|
|
194
221
|
z: 1,
|
|
@@ -204,25 +231,25 @@ export const getOption = async (
|
|
|
204
231
|
itemStyle: {
|
|
205
232
|
color: "#666",
|
|
206
233
|
},
|
|
207
|
-
}
|
|
234
|
+
},
|
|
208
235
|
],
|
|
209
236
|
toolbox: {
|
|
210
237
|
show: false,
|
|
211
238
|
},
|
|
212
239
|
brush: {
|
|
213
|
-
xAxisIndex:
|
|
214
|
-
brushLink:
|
|
240
|
+
xAxisIndex: "all",
|
|
241
|
+
brushLink: "all",
|
|
215
242
|
transformable: false,
|
|
216
243
|
outOfBrush: {
|
|
217
244
|
colorAlpha: 1,
|
|
218
245
|
},
|
|
219
246
|
brushStyle: {
|
|
220
|
-
color:
|
|
221
|
-
borderColor:
|
|
247
|
+
color: "rgba(120,140,180,0)",
|
|
248
|
+
borderColor: "rgba(255,255,255,0.4)",
|
|
222
249
|
},
|
|
223
250
|
},
|
|
224
|
-
}
|
|
225
|
-
}
|
|
251
|
+
};
|
|
252
|
+
};
|
|
226
253
|
|
|
227
254
|
/**
|
|
228
255
|
* @description: 格式化其他画线配置项
|
|
@@ -233,38 +260,38 @@ export const getOption = async (
|
|
|
233
260
|
* @return {graphicType} graphic绘线配置
|
|
234
261
|
*/
|
|
235
262
|
export const getLineOption = (data: LineDataType, config: InConfig, echartsInstance: EChartsType) => {
|
|
236
|
-
const { gridLeft, gridRight, warningConfig, positionConfig, conditionConfig } = config
|
|
237
|
-
let elements: any = []
|
|
263
|
+
const { gridLeft, gridRight, warningConfig, positionConfig, conditionConfig } = config;
|
|
264
|
+
let elements: any = [];
|
|
238
265
|
|
|
239
|
-
if (
|
|
240
|
-
const [minValue, maxValue] = (echartsInstance as any).getModel().getComponent(
|
|
266
|
+
if ((echartsInstance as any)?.getModel()?.getComponent) {
|
|
267
|
+
const [minValue, maxValue] = (echartsInstance as any).getModel().getComponent("yAxis").axis.scale._extent;
|
|
241
268
|
// -----数据初始化----
|
|
242
|
-
let warningData: WarningDataItem[] = []
|
|
243
|
-
let warningEvent: GraphicEvent = {}
|
|
244
|
-
let positionData: PositionDataItem[] = []
|
|
245
|
-
let positionEvent: GraphicEvent = {}
|
|
246
|
-
let conditionData: ConditionDataItem[] = []
|
|
247
|
-
let conditionEvent: GraphicEvent = {}
|
|
269
|
+
let warningData: WarningDataItem[] = [];
|
|
270
|
+
let warningEvent: GraphicEvent = {};
|
|
271
|
+
let positionData: PositionDataItem[] = [];
|
|
272
|
+
let positionEvent: GraphicEvent = {};
|
|
273
|
+
let conditionData: ConditionDataItem[] = [];
|
|
274
|
+
let conditionEvent: GraphicEvent = {};
|
|
248
275
|
data.forEach(({ key, data, ...events }) => {
|
|
249
|
-
if (key ===
|
|
250
|
-
warningData = data as WarningDataItem[]
|
|
251
|
-
warningEvent = events
|
|
252
|
-
} else if (key ===
|
|
253
|
-
positionData = data as PositionDataItem[]
|
|
254
|
-
positionEvent = events
|
|
255
|
-
} else if (key ===
|
|
256
|
-
conditionData = data as ConditionDataItem[]
|
|
257
|
-
conditionEvent = events
|
|
276
|
+
if (key === "warning") {
|
|
277
|
+
warningData = data as WarningDataItem[];
|
|
278
|
+
warningEvent = events;
|
|
279
|
+
} else if (key === "position") {
|
|
280
|
+
positionData = data as PositionDataItem[];
|
|
281
|
+
positionEvent = events;
|
|
282
|
+
} else if (key === "condition") {
|
|
283
|
+
conditionData = data as ConditionDataItem[];
|
|
284
|
+
conditionEvent = events;
|
|
258
285
|
}
|
|
259
|
-
})
|
|
260
|
-
|
|
286
|
+
});
|
|
287
|
+
|
|
261
288
|
// -----处理预警线-----
|
|
262
289
|
if (warningData.length > 0) {
|
|
263
290
|
elements = warningData.reduce((res, item: WarningDataItem) => {
|
|
264
|
-
const { value, text, info, config } = item
|
|
291
|
+
const { value, text, info, config } = item;
|
|
265
292
|
if (value > maxValue || value < minValue) {
|
|
266
293
|
// 当前数值超出图表范围,不绘制
|
|
267
|
-
return res
|
|
294
|
+
return res;
|
|
268
295
|
}
|
|
269
296
|
const params = {
|
|
270
297
|
y: echartsInstance.convertToPixel({ yAxisIndex: 0 }, value),
|
|
@@ -274,18 +301,18 @@ export const getLineOption = (data: LineDataType, config: InConfig, echartsInsta
|
|
|
274
301
|
gridRight,
|
|
275
302
|
echartsWidth: echartsInstance.getWidth(),
|
|
276
303
|
echartsInstance,
|
|
277
|
-
}
|
|
278
|
-
return [...res, getWarningItem(params)]
|
|
279
|
-
}, elements)
|
|
304
|
+
};
|
|
305
|
+
return [...res, getWarningItem(params)];
|
|
306
|
+
}, elements);
|
|
280
307
|
}
|
|
281
308
|
// -----处理持仓线-----
|
|
282
309
|
if (positionData.length > 0) {
|
|
283
310
|
elements = positionData.reduce((res, item: PositionDataItem) => {
|
|
284
|
-
const { value, text, info, config } = item
|
|
311
|
+
const { value, text, info, config } = item;
|
|
285
312
|
// 数值超出图表范围的不绘制, 直接return
|
|
286
313
|
if (value > maxValue || value < minValue) {
|
|
287
314
|
// 当前数值超出图表范围,不绘制
|
|
288
|
-
return res
|
|
315
|
+
return res;
|
|
289
316
|
}
|
|
290
317
|
const params = {
|
|
291
318
|
y: echartsInstance.convertToPixel({ yAxisIndex: 0 }, value),
|
|
@@ -295,17 +322,17 @@ export const getLineOption = (data: LineDataType, config: InConfig, echartsInsta
|
|
|
295
322
|
gridRight,
|
|
296
323
|
echartsWidth: echartsInstance.getWidth(),
|
|
297
324
|
echartsInstance,
|
|
298
|
-
}
|
|
299
|
-
return [...res, getPositionItem(params)]
|
|
300
|
-
}, elements)
|
|
325
|
+
};
|
|
326
|
+
return [...res, getPositionItem(params)];
|
|
327
|
+
}, elements);
|
|
301
328
|
}
|
|
302
329
|
// -----处理条件单-----
|
|
303
330
|
if (conditionData.length > 0) {
|
|
304
331
|
elements = conditionData.reduce((res, item: ConditionDataItem) => {
|
|
305
|
-
const { value, text, profitValue, profitText, lossValue, lossText, info, config } = item
|
|
332
|
+
const { value, text, profitValue, profitText, lossValue, lossText, info, config } = item;
|
|
306
333
|
// 数值超出图表范围的不绘制, 直接return
|
|
307
334
|
if (value > maxValue || value < minValue) {
|
|
308
|
-
return res
|
|
335
|
+
return res;
|
|
309
336
|
}
|
|
310
337
|
const params = {
|
|
311
338
|
y: echartsInstance.convertToPixel({ yAxisIndex: 0 }, value),
|
|
@@ -319,12 +346,12 @@ export const getLineOption = (data: LineDataType, config: InConfig, echartsInsta
|
|
|
319
346
|
gridRight,
|
|
320
347
|
echartsWidth: echartsInstance.getWidth(),
|
|
321
348
|
echartsInstance,
|
|
322
|
-
}
|
|
323
|
-
return [...res, getConditionItem(params)]
|
|
324
|
-
}, elements)
|
|
349
|
+
};
|
|
350
|
+
return [...res, getConditionItem(params)];
|
|
351
|
+
}, elements);
|
|
325
352
|
}
|
|
326
353
|
}
|
|
327
354
|
|
|
328
355
|
// -----return------
|
|
329
|
-
return { elements }
|
|
330
|
-
}
|
|
356
|
+
return { elements };
|
|
357
|
+
};
|