st-comp 0.0.207 → 0.0.209

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/es/KlineNew.js CHANGED
@@ -22,19 +22,19 @@ import "./debounce-8d53f4dd.js";
22
22
  import "./vnode-5ddb7ed1.js";
23
23
  const oe = /* @__PURE__ */ R({
24
24
  __name: "index",
25
- setup(k, { expose: D }) {
26
- let S = !1, h = !0, v = [];
27
- const y = (f, c) => f.length > c ? f.slice(f.length - c) : f;
28
- return D({
25
+ setup(w, { expose: A }) {
26
+ let S = !1, h = !0, D = [];
27
+ const b = (f, c) => f.length > c ? f.slice(f.length - c) : f;
28
+ return A({
29
29
  // 注册计算指标线方法
30
30
  initTalib: async () => {
31
31
  if (!S)
32
- S = !0, await te("./talib.wasm"), h = !1, v.forEach((f) => {
32
+ S = !0, await te("./talib.wasm"), h = !1, D.forEach((f) => {
33
33
  f();
34
34
  });
35
35
  else if (h)
36
36
  return new Promise((f) => {
37
- v.push(f);
37
+ D.push(f);
38
38
  });
39
39
  },
40
40
  // 键盘事件处理
@@ -89,42 +89,42 @@ const oe = /* @__PURE__ */ R({
89
89
  * }
90
90
  */
91
91
  formatDataBySlide: (f) => {
92
- const { originDrawData: c, addData: o, startTime: u, endTime: p } = f, { mainIndicator: d, mainIndicatorList: e, subIndicator: i, subIndicatorList: t, config: a, timeRange: r } = f, { loadAddCount: x, preLoadCount: A } = a;
93
- let g = [], _ = [], F = [], I = [];
94
- u && p ? (g = o.filter((l) => new Date(l[0]) >= new Date(u) && new Date(l[0]) <= new Date(p)), I = [...o]) : p ? (g = [
92
+ const { originDrawData: c, addData: o, startTime: u, endTime: p } = f, { mainIndicator: d, mainIndicatorList: e, subIndicator: i, subIndicatorList: t, config: a, timeRange: r } = f, { loadAddCount: x, preLoadCount: k } = a;
93
+ let g = [], _ = [], F = [], y = [];
94
+ u && p ? (g = o.filter((l) => new Date(l[0]) >= new Date(u) && new Date(l[0]) <= new Date(p)), y = [...o]) : p ? (g = [
95
95
  ...o.filter((l, n) => n >= o.length - x && new Date(r[0]) <= new Date(l[0]) && new Date(l[0]) <= new Date(r[1])),
96
96
  ...c.originData
97
- ], I = [...o, ...c.originData]) : u && (g = [
97
+ ], y = [...o, ...c.originData]) : u && (g = [
98
98
  ...c.originData,
99
- ...o.filter((l, n) => n >= A && new Date(r[0]) <= new Date(l[0]) && new Date(l[0]) <= new Date(r[1]))
100
- ], I = g), g.forEach((l, n) => {
99
+ ...o.filter((l, n) => n >= k && new Date(r[0]) <= new Date(l[0]) && new Date(l[0]) <= new Date(r[1]))
100
+ ], y = g), g.forEach((l, n) => {
101
101
  _.push([l[1], l[4], l[3], l[2], n === 0 ? 0 : g[n - 1][4], l[6]]), F.push(l[0]);
102
102
  });
103
103
  let s = [], m = [];
104
- const b = {
104
+ const v = {
105
105
  time: [],
106
106
  open: [],
107
107
  close: [],
108
108
  high: [],
109
109
  low: [],
110
- originData: I
110
+ originData: y
111
111
  };
112
112
  let E = null, C = null;
113
- return I.forEach((l, n) => {
114
- b.time.push(l[0]), b.open.push(l[1]), b.close.push(l[4]), b.high.push(l[2]), b.low.push(l[3]), l[0] === g[0][0] && (E = n), l[0] === g[g.length - 1][0] && (C = n + 1);
113
+ return y.forEach((l, n) => {
114
+ v.time.push(l[0]), v.open.push(l[1]), v.close.push(l[4]), v.high.push(l[2]), v.low.push(l[3]), l[0] === g[0][0] && (E = n), l[0] === g[g.length - 1][0] && (C = n + 1);
115
115
  }), s = e.find(({ value: l }) => l === d).config.map((l) => {
116
116
  const { calculationFn: n } = l;
117
117
  return {
118
118
  ...l,
119
- data: n ? n(z, b, { time: [], open: [], close: [], high: [], low: [], originData: [] }).slice(E, C) : []
119
+ data: n ? n(z, v, { time: [], open: [], close: [], high: [], low: [], originData: [] }).slice(E, C) : []
120
120
  };
121
121
  }), m = t.find(({ value: l }) => l === i).config.reduce((l, n) => {
122
- const { source: w, calculationFn: V } = n;
123
- return w === "calculation" ? [
122
+ const { source: I, calculationFn: V } = n;
123
+ return I === "calculation" ? [
124
124
  ...l,
125
125
  {
126
126
  ...n,
127
- data: V ? V(z, b).slice(E, C) : []
127
+ data: V ? V(z, v).slice(E, C) : []
128
128
  }
129
129
  ] : l;
130
130
  }, []), {
@@ -142,14 +142,14 @@ const oe = /* @__PURE__ */ R({
142
142
  formatDataByCount: (f) => {
143
143
  const { originDrawData: c, addData: o, mainIndicator: u, mainIndicatorList: p, subIndicator: d, subIndicatorList: e, config: i } = f;
144
144
  let t = {};
145
- const { addCount: a, preLoadCount: r } = i, x = [], A = [], g = [], _ = [], F = [];
146
- let I = [], s = [];
147
- const m = o.filter((n, w) => (x.push(n[0]), A.push(n[1]), g.push(n[4]), _.push(n[2]), F.push(n[3]), I.push(n[0]), s.push([n[1], n[4], n[3], n[2], w === 0 ? 0 : o[w - 1][4], n[6]]), o.length >= a + r - 1 ? w >= r : !0));
148
- I = y(I, m.length), s = y(s, m.length);
149
- const b = { time: x, open: A, close: g, high: _, low: F, originData: o }, C = p.find((n) => n.value === u).config.map((n) => ({
145
+ const { addCount: a, preLoadCount: r } = i, x = [], k = [], g = [], _ = [], F = [];
146
+ let y = [], s = [];
147
+ const m = o.filter((n, I) => (x.push(n[0]), k.push(n[1]), g.push(n[4]), _.push(n[2]), F.push(n[3]), y.push(n[0]), s.push([n[1], n[4], n[3], n[2], I === 0 ? 0 : o[I - 1][4], n[6]]), o.length >= a + r - 1 ? I >= r : !0));
148
+ y = b(y, m.length), s = b(s, m.length);
149
+ const v = { time: x, open: k, close: g, high: _, low: F, originData: o }, C = p.find((n) => n.value === u).config.map((n) => ({
150
150
  ...n,
151
- data: y(
152
- n.calculationFn ? n.calculationFn(z, b, {
151
+ data: b(
152
+ n.calculationFn ? n.calculationFn(z, v, {
153
153
  time: [],
154
154
  open: [],
155
155
  close: [],
@@ -157,40 +157,40 @@ const oe = /* @__PURE__ */ R({
157
157
  low: [],
158
158
  originData: []
159
159
  }) : [],
160
- I.length
160
+ y.length
161
161
  )
162
162
  }));
163
163
  let l = [];
164
- return d && e && (l = e.find((w) => w.value === d).config.reduce((w, V) => V.source === "calculation" ? [
165
- ...w,
164
+ return d && e && (l = e.find((I) => I.value === d).config.reduce((I, V) => V.source === "calculation" ? [
165
+ ...I,
166
166
  {
167
167
  ...V,
168
- data: y(
169
- V.calculationFn ? V.calculationFn(z, b) : [],
170
- I.length
168
+ data: b(
169
+ V.calculationFn ? V.calculationFn(z, v) : [],
170
+ y.length
171
171
  )
172
172
  }
173
- ] : w, [])), c.length ? t = {
173
+ ] : I, [])), c.length ? t = {
174
174
  originData: [...m, ...c.originData],
175
175
  // 原数据
176
- xAxisData: [...I, ...c.xAxisData],
176
+ xAxisData: [...y, ...c.xAxisData],
177
177
  // 时间数据
178
178
  candlestickData: [...s, ...c.candlestickData],
179
179
  // k线数据
180
- mainIndicatorData: c.mainIndicatorData.map((n, w) => ({
180
+ mainIndicatorData: c.mainIndicatorData.map((n, I) => ({
181
181
  ...n,
182
- data: [...C[w].data, ...n.data]
182
+ data: [...C[I].data, ...n.data]
183
183
  })),
184
184
  // 主图指标线数据
185
- subIndicatorData: c.subIndicatorData.map((n, w) => ({
185
+ subIndicatorData: c.subIndicatorData.map((n, I) => ({
186
186
  ...n,
187
- data: [...l[w].data, ...n.data]
187
+ data: [...l[I].data, ...n.data]
188
188
  }))
189
189
  // 副图数据
190
190
  } : t = {
191
191
  originData: m,
192
192
  // 原数据
193
- xAxisData: I,
193
+ xAxisData: y,
194
194
  // 时间数据
195
195
  candlestickData: s,
196
196
  // k线数据
@@ -213,10 +213,10 @@ const oe = /* @__PURE__ */ R({
213
213
  require: !0
214
214
  }
215
215
  },
216
- setup(k) {
217
- return (D, S) => (T(), L("div", re, [
218
- (T(!0), L(K, null, Z(k.data, (h, v) => (T(), L("div", {
219
- key: v,
216
+ setup(w) {
217
+ return (A, S) => (T(), L("div", re, [
218
+ (T(!0), L(K, null, Z(w.data, (h, D) => (T(), L("div", {
219
+ key: D,
220
220
  class: "kline-tips-item",
221
221
  style: H({ color: h.color })
222
222
  }, N(h.label) + " " + N(h.value), 5))), 128))
@@ -248,28 +248,28 @@ const M = /* @__PURE__ */ q(ie, [["__scopeId", "data-v-2a02e841"]]), le = { clas
248
248
  require: !0
249
249
  }
250
250
  },
251
- setup(k) {
252
- const { round: D, multiply: S, divide: h, subtract: v, formatValue: y } = G, f = k, c = $(() => {
251
+ setup(w) {
252
+ const { round: A, multiply: S, divide: h, subtract: D, formatValue: b } = G, f = w, c = $(() => {
253
253
  const { drawData: u, activeIndex: p, candlestickData: d } = f;
254
254
  if (d != null && d.length && d[p]) {
255
255
  let e;
256
256
  return d[p][6] > 0 ? e = "red" : d[p][6] < 0 && (e = "green"), [
257
- { label: "开", value: D(d[p][0]) },
258
- { label: "高", value: D(d[p][3]) },
259
- { label: "低", value: D(d[p][2]) },
260
- { label: "收", value: D(d[p][1]) },
261
- { label: "额", value: y(d[p][4]) },
262
- { label: "涨跌", value: `${D(d[p][6])}%`, color: e }
257
+ { label: "开", value: d[p][0] },
258
+ { label: "高", value: d[p][3] },
259
+ { label: "低", value: d[p][2] },
260
+ { label: "收", value: d[p][1] },
261
+ { label: "额", value: b(d[p][4]) },
262
+ { label: "涨跌", value: `${A(d[p][6])}%`, color: e }
263
263
  ];
264
264
  } else if (u.candlestickData && u.candlestickData[p]) {
265
265
  const e = u.candlestickData[p], i = [
266
- { label: "开", value: D(e[0]) },
267
- { label: "高", value: D(e[3]) },
268
- { label: "低", value: D(e[2]) },
269
- { label: "收", value: D(e[1]) }
266
+ { label: "开", value: e[0] },
267
+ { label: "高", value: e[3] },
268
+ { label: "低", value: e[2] },
269
+ { label: "收", value: e[1] }
270
270
  ];
271
- e[5] !== void 0 && i.push({ label: "额", value: y(e[5]) });
272
- const t = D(S(h(v(e[1], e[4]), Math.abs(e[4])), 100));
271
+ e[5] !== void 0 && i.push({ label: "额", value: b(e[5]) });
272
+ const t = A(S(h(D(e[1], e[4]), Math.abs(e[4])), 100));
273
273
  let a;
274
274
  return t > 0 ? a = "red" : t < 0 && (a = "green"), i.push({ label: "涨跌", value: `${t}%`, color: a }), i;
275
275
  }
@@ -277,7 +277,7 @@ const M = /* @__PURE__ */ q(ie, [["__scopeId", "data-v-2a02e841"]]), le = { clas
277
277
  }), o = $(() => {
278
278
  var d;
279
279
  const { drawData: u, activeIndex: p } = f;
280
- return ((d = u == null ? void 0 : u.mainIndicatorData) == null ? void 0 : d.map((e) => ({ label: e.key, value: D(e.data[p]), color: e.color }))) || [];
280
+ return ((d = u == null ? void 0 : u.mainIndicatorData) == null ? void 0 : d.map((e) => ({ label: e.key, value: A(e.data[p]), color: e.color }))) || [];
281
281
  });
282
282
  return (u, p) => (T(), L("div", le, [
283
283
  O(M, { data: c.value }, null, 8, ["data"]),
@@ -285,7 +285,7 @@ const M = /* @__PURE__ */ q(ie, [["__scopeId", "data-v-2a02e841"]]), le = { clas
285
285
  ]));
286
286
  }
287
287
  });
288
- const ce = /* @__PURE__ */ q(se, [["__scopeId", "data-v-234f3f41"]]), ue = { class: "klineSub" }, de = { class: "klineSub-tips" }, pe = {
288
+ const ce = /* @__PURE__ */ q(se, [["__scopeId", "data-v-e75a1234"]]), ue = { class: "klineSub" }, de = { class: "klineSub-tips" }, pe = {
289
289
  key: 0,
290
290
  class: "klineSub-tips-select"
291
291
  }, fe = /* @__PURE__ */ R({
@@ -301,10 +301,10 @@ const ce = /* @__PURE__ */ q(se, [["__scopeId", "data-v-234f3f41"]]), ue = { cla
301
301
  // 配置
302
302
  },
303
303
  emits: ["update:modelValue"],
304
- setup(k, { expose: D, emit: S }) {
304
+ setup(w, { expose: A, emit: S }) {
305
305
  const { round: h } = G;
306
- let v, y;
307
- const f = S, c = k, o = j(), u = $({
306
+ let D, b;
307
+ const f = S, c = w, o = j(), u = $({
308
308
  get() {
309
309
  return c.modelValue;
310
310
  },
@@ -314,9 +314,9 @@ const ce = /* @__PURE__ */ q(se, [["__scopeId", "data-v-234f3f41"]]), ue = { cla
314
314
  }), p = $(() => {
315
315
  const { drawData: e, activeIndex: i } = c, t = c.subIndicatorList.find((a) => a.value === u.value);
316
316
  return e.originData && e.originData[i] ? t.config.map((a) => {
317
- var x, A;
317
+ var x, k;
318
318
  let r = "-";
319
- return a.source === "origin" ? r = e.originData[i][a.dataIndex] || "-" : a.source === "calculation" && (r = (((A = (x = e.subIndicatorData) == null ? void 0 : x.find((_) => _.key === a.key)) == null ? void 0 : A.data) || [])[i]), {
319
+ return a.source === "origin" ? r = e.originData[i][a.dataIndex] || "-" : a.source === "calculation" && (r = (((k = (x = e.subIndicatorData) == null ? void 0 : x.find((_) => _.key === a.key)) == null ? void 0 : k.data) || [])[i]), {
320
320
  label: a.key,
321
321
  color: a.color,
322
322
  value: r === "-" ? r : h(r)
@@ -324,17 +324,17 @@ const ce = /* @__PURE__ */ q(se, [["__scopeId", "data-v-234f3f41"]]), ue = { cla
324
324
  }) : [];
325
325
  });
326
326
  U(() => {
327
- v = B.init(o.value);
327
+ D = B.init(o.value);
328
328
  let e = !0;
329
- y = new ResizeObserver(() => {
329
+ b = new ResizeObserver(() => {
330
330
  if (e) {
331
331
  e = null;
332
332
  return;
333
333
  }
334
- v.resize();
335
- }), y.observe(o.value);
334
+ D.resize();
335
+ }), b.observe(o.value);
336
336
  }), Y(() => {
337
- v.dispose(), y.disconnect(), y = null;
337
+ D.dispose(), b.disconnect(), b = null;
338
338
  });
339
339
  const d = (e, i) => {
340
340
  const t = e[i], a = i === 0 ? e[i] : e[i - 1];
@@ -350,27 +350,27 @@ const ce = /* @__PURE__ */ q(se, [["__scopeId", "data-v-234f3f41"]]), ue = { cla
350
350
  color: "#00FFFF"
351
351
  };
352
352
  };
353
- return D({
353
+ return A({
354
354
  connect: (e) => {
355
- B.connect([e, v]);
355
+ B.connect([e, D]);
356
356
  },
357
357
  // 联动
358
358
  draw: (e) => {
359
359
  J(() => {
360
- var I;
361
- const { startValue: i, endValue: t, maxValueSpan: a } = e, { xAxisData: r, subIndicatorData: x, candlestickData: A, originData: g } = c.drawData, _ = c.subIndicatorList.find((s) => s.value === u.value), F = [];
360
+ var y;
361
+ const { startValue: i, endValue: t, maxValueSpan: a } = e, { xAxisData: r, subIndicatorData: x, candlestickData: k, originData: g } = c.drawData, _ = c.subIndicatorList.find((s) => s.value === u.value), F = [];
362
362
  if (_.series === "bar") {
363
363
  let s = [];
364
- _.source === "origin" ? s = g.map((m) => m[_.dataIndex]) : s = ((I = x == null ? void 0 : x.find((m) => m.key === _.dataIndex)) == null ? void 0 : I.data) || [], F.push({
364
+ _.source === "origin" ? s = g.map((m) => m[_.dataIndex]) : s = ((y = x == null ? void 0 : x.find((m) => m.key === _.dataIndex)) == null ? void 0 : y.data) || [], F.push({
365
365
  name: "subMain",
366
366
  xAxisIndex: 0,
367
367
  yAxisIndex: 1,
368
368
  type: "bar",
369
369
  silent: !0,
370
370
  symbol: "none",
371
- data: s.map((m, b) => _.color === "kline" ? {
371
+ data: s.map((m, v) => _.color === "kline" ? {
372
372
  value: m,
373
- itemStyle: d(A, b)
373
+ itemStyle: d(k, v)
374
374
  } : _.color === "value" ? {
375
375
  value: m,
376
376
  itemStyle: {
@@ -387,7 +387,7 @@ const ce = /* @__PURE__ */ q(se, [["__scopeId", "data-v-234f3f41"]]), ue = { cla
387
387
  x.forEach((s) => {
388
388
  if (s.series === "line") {
389
389
  let m = [];
390
- s.source === "origin" ? m = g.map((b) => b[s.dataIndex]) : s.source === "calculation" && (m = s.data), F.push({
390
+ s.source === "origin" ? m = g.map((v) => v[s.dataIndex]) : s.source === "calculation" && (m = s.data), F.push({
391
391
  xAxisIndex: 0,
392
392
  yAxisIndex: s.yAxis === "right" ? 2 : 1,
393
393
  name: s.key,
@@ -403,7 +403,7 @@ const ce = /* @__PURE__ */ q(se, [["__scopeId", "data-v-234f3f41"]]), ue = { cla
403
403
  }
404
404
  });
405
405
  }
406
- }), v.setOption(
406
+ }), D.setOption(
407
407
  {
408
408
  animation: !1,
409
409
  grid: {
@@ -429,11 +429,11 @@ const ce = /* @__PURE__ */ q(se, [["__scopeId", "data-v-234f3f41"]]), ue = { cla
429
429
  label: {
430
430
  rich: {},
431
431
  formatter: (s) => {
432
- const { axisDimension: m, value: b } = s;
432
+ const { axisDimension: m, value: v } = s;
433
433
  if (m === "x")
434
- return b;
434
+ return v;
435
435
  if (s.axisIndex === 1)
436
- return String(h(b));
436
+ return String(h(v));
437
437
  }
438
438
  }
439
439
  },
@@ -509,7 +509,7 @@ const ce = /* @__PURE__ */ q(se, [["__scopeId", "data-v-234f3f41"]]), ue = { cla
509
509
  class: "element-dark subIndicator"
510
510
  }, {
511
511
  default: Q(() => [
512
- (T(!0), L(K, null, Z(k.subIndicatorList, (r) => (T(), W(t, {
512
+ (T(!0), L(K, null, Z(w.subIndicatorList, (r) => (T(), W(t, {
513
513
  key: r.value,
514
514
  label: r.label,
515
515
  value: r.value
@@ -536,9 +536,9 @@ const he = /* @__PURE__ */ q(fe, [["__scopeId", "data-v-0a2f256e"]]), me = /* @_
536
536
  // 时间数据
537
537
  },
538
538
  emits: ["change"],
539
- setup(k, { expose: D, emit: S }) {
540
- let h, v, y = null;
541
- const f = S, c = k, o = j();
539
+ setup(w, { expose: A, emit: S }) {
540
+ let h, D, b = null;
541
+ const f = S, c = w, o = j();
542
542
  ee(
543
543
  () => c.data,
544
544
  () => {
@@ -548,21 +548,21 @@ const he = /* @__PURE__ */ q(fe, [["__scopeId", "data-v-0a2f256e"]]), me = /* @_
548
548
  ), U(() => {
549
549
  h = B.init(o.value), u(), d();
550
550
  let e = !0;
551
- v = new ResizeObserver(() => {
551
+ D = new ResizeObserver(() => {
552
552
  if (e) {
553
553
  e = null;
554
554
  return;
555
555
  }
556
556
  h.resize();
557
- }), v.observe(o.value);
557
+ }), D.observe(o.value);
558
558
  }), Y(() => {
559
- h.off("datazoom"), h.dispose(), v.disconnect(), v = null;
559
+ h.off("datazoom"), h.dispose(), D.disconnect(), D = null;
560
560
  });
561
561
  const u = () => {
562
562
  h.on("datazoom", (e) => {
563
- e.dataZoomId && (clearTimeout(y), y = setTimeout(() => {
563
+ e.dataZoomId && (clearTimeout(b), b = setTimeout(() => {
564
564
  const { data: i } = c, { start: t, end: a } = e, r = Math.floor(t * i.length / 100), x = a === 100 ? i.length - 1 : Math.floor(a * i.length / 100);
565
- p(r, x), clearTimeout(y);
565
+ p(r, x), clearTimeout(b);
566
566
  }, 100));
567
567
  });
568
568
  }, p = (e, i) => {
@@ -601,11 +601,11 @@ const he = /* @__PURE__ */ q(fe, [["__scopeId", "data-v-0a2f256e"]]), me = /* @_
601
601
  ]
602
602
  }, !0);
603
603
  };
604
- return D({
604
+ return A({
605
605
  resetSlide: (e, i, t) => {
606
606
  let a = -1, r = -1;
607
- c.data.forEach((x, A) => {
608
- a === -1 && x[0] === e ? a = A : a === -1 && new Date(x[0]) > new Date(e) && (a = A - 1), (r === -1 && x[0] === i || r === -1 && new Date(x[0]) > new Date(i)) && (r = A);
607
+ c.data.forEach((x, k) => {
608
+ a === -1 && x[0] === e ? a = k : a === -1 && new Date(x[0]) > new Date(e) && (a = k - 1), (r === -1 && x[0] === i || r === -1 && new Date(x[0]) > new Date(i)) && (r = k);
609
609
  }), r = r === -1 ? c.data.length - 1 : r, h.setOption({
610
610
  dataZoom: [
611
611
  {
@@ -638,8 +638,8 @@ const he = /* @__PURE__ */ q(fe, [["__scopeId", "data-v-0a2f256e"]]), me = /* @_
638
638
  }
639
639
  });
640
640
  const ge = /* @__PURE__ */ q(me, [["__scopeId", "data-v-5008746a"]]), qe = {
641
- install(k) {
642
- k.component("st-klineUtils", oe), k.component("st-klineSub", he), k.component("st-klineTips", ce), k.component("st-klineSlide", ge);
641
+ install(w) {
642
+ w.component("st-klineUtils", oe), w.component("st-klineSub", he), w.component("st-klineTips", ce), w.component("st-klineSlide", ge);
643
643
  }
644
644
  };
645
645
  export {