@wick-charts/vue 0.8.1 → 0.8.2

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.
Files changed (38) hide show
  1. package/dist/BandSeries.vue.js +25 -24
  2. package/dist/BarSeries.vue.js +27 -26
  3. package/dist/CandlestickSeries.vue.js +25 -24
  4. package/dist/HeatmapSeries.vue.js +21 -20
  5. package/dist/LineSeries.vue.js +24 -23
  6. package/dist/PieSeries.vue.js +25 -24
  7. package/dist/composables.js +63 -36
  8. package/dist/core/dist/axis/dom-labels.js +64 -53
  9. package/dist/core/dist/chart/options.js +1 -1
  10. package/dist/core/dist/chart/y-target.js +38 -32
  11. package/dist/core/dist/chart.js +475 -439
  12. package/dist/core/dist/data/decimation.js +52 -51
  13. package/dist/core/dist/data/store.js +38 -20
  14. package/dist/core/dist/data/sync.js +80 -69
  15. package/dist/core/dist/perf/perf-hud.js +3 -3
  16. package/dist/core/dist/scales/tick-tracker.js +2 -1
  17. package/dist/core/dist/series/band.js +1 -1
  18. package/dist/core/dist/series/bar.js +240 -211
  19. package/dist/core/dist/series/base-multi-layer.js +267 -249
  20. package/dist/core/dist/series/candlestick.js +116 -116
  21. package/dist/core/dist/series/line.js +540 -455
  22. package/dist/core/dist/snapshots.js +96 -77
  23. package/dist/index.d.ts +22 -4
  24. package/dist/ui/InfoBar.vue.js +68 -68
  25. package/dist/ui/NumberFlow.vue.js +36 -27
  26. package/dist/ui/Tooltip.vue.js +127 -130
  27. package/package.json +2 -2
  28. package/src/BandSeries.vue +5 -3
  29. package/src/BarSeries.vue +5 -3
  30. package/src/CandlestickSeries.vue +5 -4
  31. package/src/ChartContainer.vue +1 -1
  32. package/src/HeatmapSeries.vue +5 -4
  33. package/src/LineSeries.vue +5 -3
  34. package/src/PieSeries.vue +6 -5
  35. package/src/composables.ts +64 -1
  36. package/src/ui/InfoBar.vue +11 -3
  37. package/src/ui/NumberFlow.vue +17 -3
  38. package/src/ui/Tooltip.vue +23 -12
@@ -1,124 +1,143 @@
1
- import { isGapPoint as f, pointValue as y } from "./utils/point.js";
1
+ import { isGapPoint as f, pointValue as h } from "./utils/point.js";
2
+ import { formatDate as x } from "./utils/time.js";
2
3
  const g = /* @__PURE__ */ new WeakMap();
3
- function I(e, r) {
4
- return g.get(e)?.get(r);
4
+ function I(e, t) {
5
+ return g.get(e)?.get(t);
5
6
  }
6
- function b(e, r, n) {
7
- let o = g.get(e);
8
- o || (o = /* @__PURE__ */ new Map(), g.set(e, o)), o.set(r, n);
7
+ function y(e, t, o) {
8
+ let n = g.get(e);
9
+ n || (n = /* @__PURE__ */ new Map(), g.set(e, n)), n.set(t, o);
9
10
  }
10
- function h(e) {
11
- const r = e.low !== void 0 && e.high !== void 0 ? { time: e.time, low: e.low, high: e.high } : { time: e.time, value: e.value };
12
- return e.x !== void 0 && (r.x = e.x), r;
11
+ function b(e) {
12
+ const t = e.low !== void 0 && e.high !== void 0 ? { time: e.time, low: e.low, high: e.high } : { time: e.time, value: e.value };
13
+ return e.x !== void 0 && (t.x = e.x), t;
13
14
  }
14
- function S(e, r) {
15
- if (r === "none" || e.length <= 1) return e;
16
- const n = [...e];
17
- return n.sort((o, a) => {
18
- const s = y(o.data), i = y(a.data);
19
- return r === "asc" ? s - i : i - s;
20
- }), n;
15
+ function S(e, t) {
16
+ if (t === "none" || e.length <= 1) return e;
17
+ const o = [...e];
18
+ return o.sort((n, r) => {
19
+ const s = h(n.data), c = h(r.data);
20
+ return t === "asc" ? s - c : c - s;
21
+ }), o;
21
22
  }
22
23
  function m(e) {
23
- const r = Object.freeze({ ...e.data }), n = {
24
+ const t = Object.freeze({ ...e.data }), o = {
24
25
  id: e.id,
25
26
  seriesId: e.seriesId,
26
27
  layerIndex: e.layerIndex,
27
28
  label: e.label,
28
- data: r,
29
- color: e.color
29
+ data: t,
30
+ color: e.color,
31
+ ...e.share === void 0 ? {} : { share: e.share }
30
32
  };
31
- return Object.freeze(n);
33
+ return Object.freeze(o);
32
34
  }
33
- function x(e, r) {
34
- const n = r.sort ?? "none", o = e.getOverlayVersion(), a = I(e, r.cacheKey);
35
- if (a && a.version === o && a.time === r.time && a.sort === n)
36
- return a.data;
35
+ function w(e, t) {
36
+ const o = t.sort ?? "none", n = e.getSnapshotVersion(), r = I(e, t.cacheKey);
37
+ if (r && r.version === n && r.time === t.time && r.sort === o)
38
+ return r.data;
37
39
  const s = [];
38
- for (const t of e.getSeriesIds()) {
39
- if (!e.isSeriesVisible(t)) continue;
40
- if (e.getSeriesLayers(t) !== null) {
41
- const d = e.getLayerSnapshots(t, r.time);
40
+ for (const a of e.getSeriesIds()) {
41
+ if (!e.isSeriesVisible(a)) continue;
42
+ if (e.getSeriesLayers(a) !== null) {
43
+ const d = e.getLayerSnapshots(a, t.time);
42
44
  if (!d) continue;
43
- for (const l of d) {
44
- const u = h(l);
45
+ for (const i of d) {
46
+ const u = b(i);
45
47
  f(u) || s.push(
46
48
  m({
47
- id: `${t}_layer${l.layerIndex}`,
48
- seriesId: t,
49
- layerIndex: l.layerIndex,
50
- label: e.getLayerLabel(t, l.layerIndex),
49
+ id: `${a}_layer${i.layerIndex}`,
50
+ seriesId: a,
51
+ layerIndex: i.layerIndex,
52
+ label: e.getLayerLabel(a, i.layerIndex),
51
53
  data: u,
52
- color: l.color
54
+ color: i.color,
55
+ share: i.share
53
56
  })
54
57
  );
55
58
  }
56
59
  continue;
57
60
  }
58
- const c = e.getDataAtTime(t, r.time);
59
- !c || f(c) || s.push(
61
+ const l = e.getDataAtTime(a, t.time);
62
+ !l || f(l) || s.push(
60
63
  m({
61
- id: t,
62
- seriesId: t,
63
- label: e.getSeriesLabel(t),
64
- data: c,
65
- color: e.getSeriesColor(t) ?? "#888"
64
+ id: a,
65
+ seriesId: a,
66
+ label: e.getSeriesLabel(a),
67
+ data: l,
68
+ color: e.getSeriesColor(a) ?? "#888"
66
69
  })
67
70
  );
68
71
  }
69
- const i = Object.freeze(S(s, n));
70
- return b(e, r.cacheKey, { version: o, time: r.time, sort: n, data: i }), i;
72
+ const c = Object.freeze(S(s, o));
73
+ return y(e, t.cacheKey, { version: n, time: t.time, sort: o, data: c }), c;
71
74
  }
72
- function v(e, r) {
73
- const { time: n, snapshots: o, interval: a } = r;
74
- if (e.timeScale.getType() !== "numeric") return e.timeScale.formatX(n, a);
75
- let s = n, i = Number.POSITIVE_INFINITY;
76
- for (const t of o) {
77
- const c = Math.abs(t.data.time - n), d = c === i && t.data.time <= s;
78
- c > i || d || (i = c, s = t.data.time);
75
+ const v = 864e5;
76
+ function p(e, t) {
77
+ let o = e, n = Number.POSITIVE_INFINITY;
78
+ for (const r of t) {
79
+ const s = Math.abs(r.data.time - e), c = s === n && r.data.time <= o;
80
+ s > n || c || (n = s, o = r.data.time);
79
81
  }
80
- return e.timeScale.formatPointX(s, a);
82
+ return o;
81
83
  }
82
- function L(e, r) {
83
- const n = r.sort ?? "none", o = e.getOverlayVersion(), a = I(e, r.cacheKey);
84
- if (a && a.version === o && a.time === null && a.sort === n)
85
- return a.data;
84
+ function L(e, t) {
85
+ const o = p(t.time, t.snapshots);
86
+ return e.timeScale.formatPointX(o, t.interval);
87
+ }
88
+ function T(e, t) {
89
+ const o = L(e, t);
90
+ if (e.timeScale.getType() !== "time") return o;
91
+ const n = p(t.time, t.snapshots), r = x(n, { locale: e.timeScale.getLocale(), timeZone: e.timeScale.getTimeZone() });
92
+ return t.interval >= v && e.timeScale.getFormat() === null ? r : `${r} ${o}`;
93
+ }
94
+ function O(e, t) {
95
+ const o = t(h(e.data));
96
+ return e.share === void 0 ? o : `${Number(e.share.toFixed(1))}% · ${o}`;
97
+ }
98
+ function j(e, t) {
99
+ const o = t.sort ?? "none", n = e.getSnapshotVersion(), r = I(e, t.cacheKey);
100
+ if (r && r.version === n && r.time === null && r.sort === o)
101
+ return r.data;
86
102
  const s = [];
87
- for (const t of e.getSeriesIds()) {
88
- if (!e.isSeriesVisible(t)) continue;
89
- const c = e.getLayerLastSnapshots(t);
90
- if (c) {
91
- for (const l of c) {
92
- const u = h(l);
103
+ for (const a of e.getSeriesIds()) {
104
+ if (!e.isSeriesVisible(a)) continue;
105
+ const l = e.getLayerLastSnapshots(a);
106
+ if (l) {
107
+ for (const i of l) {
108
+ const u = b(i);
93
109
  f(u) || s.push(
94
110
  m({
95
- id: `${t}_layer${l.layerIndex}`,
96
- seriesId: t,
97
- layerIndex: l.layerIndex,
98
- label: e.getLayerLabel(t, l.layerIndex),
111
+ id: `${a}_layer${i.layerIndex}`,
112
+ seriesId: a,
113
+ layerIndex: i.layerIndex,
114
+ label: e.getLayerLabel(a, i.layerIndex),
99
115
  data: u,
100
- color: l.color
116
+ color: i.color,
117
+ share: i.share
101
118
  })
102
119
  );
103
120
  }
104
121
  continue;
105
122
  }
106
- const d = e.getLastData(t);
123
+ const d = e.getLastData(a);
107
124
  !d || f(d) || s.push(
108
125
  m({
109
- id: t,
110
- seriesId: t,
111
- label: e.getSeriesLabel(t),
126
+ id: a,
127
+ seriesId: a,
128
+ label: e.getSeriesLabel(a),
112
129
  data: d,
113
- color: e.getSeriesColor(t) ?? "#888"
130
+ color: e.getSeriesColor(a) ?? "#888"
114
131
  })
115
132
  );
116
133
  }
117
- const i = Object.freeze(S(s, n));
118
- return b(e, r.cacheKey, { version: o, time: null, sort: n, data: i }), i;
134
+ const c = Object.freeze(S(s, o));
135
+ return y(e, t.cacheKey, { version: n, time: null, sort: o, data: c }), c;
119
136
  }
120
137
  export {
121
- x as buildHoverSnapshots,
122
- L as buildLastSnapshots,
123
- v as formatHeaderX
138
+ w as buildHoverSnapshots,
139
+ j as buildLastSnapshots,
140
+ L as formatHeaderX,
141
+ O as formatRowValue,
142
+ T as formatTooltipHeader
124
143
  };
package/dist/index.d.ts CHANGED
@@ -116,6 +116,7 @@ declare type __VLS_Props_13 = {
116
116
  */
117
117
  format?: ((value: number) => string) | Intl.NumberFormatOptions;
118
118
  locale?: string;
119
+ /** Per-digit spin duration in ms. A value that arrives sooner than this after the previous one snaps instead. */
119
120
  spinDuration?: number;
120
121
  };
121
122
 
@@ -290,7 +291,7 @@ declare type __VLS_Props_4 = {
290
291
  * Viewport padding. `top`/`bottom` are in pixels. `left`/`right` accept either pixels (`50`)
291
292
  * or data intervals (`{ intervals: 3 }`). Set to 0 for edge-to-edge sparklines. Updates are
292
293
  * applied reactively when this prop or the measured header height changes.
293
- * Defaults: `{ top: 20, bottom: 20, right: { intervals: 3 }, left: { intervals: 0 } }`.
294
+ * Defaults: `{ top: 20, bottom: 20, right: { intervals: 3 }, left: { intervals: 0.5 } }`.
294
295
  */
295
296
  padding?: {
296
297
  top?: number;
@@ -1728,7 +1729,7 @@ export declare interface BitmapCoordinateSpace {
1728
1729
  * actually be drawing.
1729
1730
  *
1730
1731
  * The result is cached per `(chart, cacheKey)` slot; as long as
1731
- * `chart.getOverlayVersion()` hasn't changed and `time`/`sort` match the
1732
+ * `chart.getSnapshotVersion()` hasn't changed and `time`/`sort` match the
1732
1733
  * cached call, the **same reference** is returned. This makes
1733
1734
  * `React.memo((a, b) => a.snapshots === b.snapshots)` skip renders on
1734
1735
  * crosshair moves that stay within one data point.
@@ -1755,7 +1756,7 @@ export declare interface BuildHoverSnapshotsArgs {
1755
1756
  * at the primary layer's timestamp.
1756
1757
  *
1757
1758
  * Cached by `(chart, cacheKey)` + `sort`, invalidated on
1758
- * `chart.getOverlayVersion()` bump. `time` is not an input, so the slot is
1759
+ * `chart.getSnapshotVersion()` bump. `time` is not an input, so the slot is
1759
1760
  * stored with `time: null`.
1760
1761
  */
1761
1762
  export declare function buildLastSnapshots(chart: ChartInstance, args: BuildLastSnapshotsArgs): readonly SeriesSnapshot[];
@@ -2082,6 +2083,13 @@ declare interface ChartEvents {
2082
2083
  * tracked tick has reached its target opacity.
2083
2084
  */
2084
2085
  tickFrame: () => void;
2086
+ /**
2087
+ * Fired once per main-layer frame while a series' displayed values animate
2088
+ * (value smoothing, entrance, layer fade, intro), and once on the frame they
2089
+ * settle. Snapshot readers (`InfoBar`, `Tooltip`) refresh off it, as
2090
+ * `buildHoverSnapshots` / `buildLastSnapshots` report those animated values.
2091
+ */
2092
+ seriesFrame: () => void;
2085
2093
  }
2086
2094
 
2087
2095
  /**
@@ -2682,7 +2690,7 @@ export declare interface ChartOptions {
2682
2690
  scales?: Record<string, YAxisConfig>;
2683
2691
  /**
2684
2692
  * Viewport padding. `top`/`bottom` are in pixels. `left`/`right` accept either pixels (`50`)
2685
- * or data intervals (`{ intervals: 3 }`). Defaults: `{ top: 20, bottom: 20, right: { intervals: 3 }, left: { intervals: 0 } }`.
2693
+ * or data intervals (`{ intervals: 3 }`). Defaults: `{ top: 20, bottom: 20, right: { intervals: 3 }, left: { intervals: 0.5 } }`.
2686
2694
  */
2687
2695
  padding?: {
2688
2696
  top?: number;
@@ -3353,6 +3361,8 @@ export declare interface LayerSnapshot {
3353
3361
  high?: number;
3354
3362
  /** The sample's own X on a numeric or category axis. */
3355
3363
  x?: number | string;
3364
+ /** On a percent stack, the row's percent of the rows listed with it. Absent elsewhere, and when they sum to 0. */
3365
+ share?: number;
3356
3366
  }
3357
3367
 
3358
3368
  export declare const Legend: __VLS_WithTemplateSlots_3<typeof __VLS_component_3, __VLS_TemplateResult_3["slots"]>;
@@ -4772,6 +4782,12 @@ export declare interface SeriesCreateEnv {
4772
4782
  theme: ChartTheme;
4773
4783
  /** Number of stacked layers requested via `layers` (`1` when omitted). */
4774
4784
  layerCount: number;
4785
+ /**
4786
+ * First `theme.seriesColors` slot for this series' default layer colours:
4787
+ * the lowest run of `layerCount` slots no other series of the same type
4788
+ * holds, so two series don't both default to the first colour. `0` when omitted.
4789
+ */
4790
+ paletteIndex?: number;
4775
4791
  }
4776
4792
 
4777
4793
  /**
@@ -4881,6 +4897,8 @@ export declare interface SeriesSnapshot {
4881
4897
  readonly label?: string;
4882
4898
  readonly data: Readonly<OHLCData> | Readonly<TimePoint> | Readonly<BandPoint>;
4883
4899
  readonly color: string;
4900
+ /** On a percent stack, the layer's share of the column in percent — what the chart draws it at. */
4901
+ readonly share?: number;
4884
4902
  }
4885
4903
 
4886
4904
  /** Primary series types. Open-ended — a custom {@link SeriesDefinition} picks any string that isn't a built-in. */
@@ -1,60 +1,60 @@
1
- import { defineComponent as W, computed as i, inject as B, ref as N, onMounted as O, onUnmounted as T, useSlots as A, unref as t, openBlock as n, createBlock as R, Teleport as $, createElementVNode as l, normalizeStyle as r, renderSlot as D, createElementBlock as s, Fragment as f, toDisplayString as p, renderList as F, createCommentVNode as L } from "vue";
2
- import { buildHoverSnapshots as M, buildLastSnapshots as P, formatHeaderX as j } from "../core/dist/snapshots.js";
3
- import { resolveCandlestickBodyColor as U } from "../core/dist/theme/resolve.js";
4
- import { formatCompact as X, formatPriceAdaptive as q } from "../core/dist/utils/format.js";
5
- import { useCrosshairPosition as G } from "../composables.js";
6
- import { useChartInstance as J, ThemeKey as Q, InfoBarAnchorKey as Y } from "../context.js";
7
- const Z = {
1
+ import { defineComponent as T, computed as s, inject as B, ref as W, onMounted as N, onUnmounted as R, useSlots as A, unref as t, openBlock as l, createBlock as D, Teleport as M, createElementVNode as r, normalizeStyle as i, renderSlot as O, createElementBlock as u, Fragment as m, toDisplayString as p, renderList as F, createCommentVNode as L } from "vue";
2
+ import { buildHoverSnapshots as P, buildLastSnapshots as $, formatHeaderX as j, formatRowValue as U } from "../core/dist/snapshots.js";
3
+ import { resolveCandlestickBodyColor as X } from "../core/dist/theme/resolve.js";
4
+ import { formatCompact as q, formatPriceAdaptive as G } from "../core/dist/utils/format.js";
5
+ import { useCrosshairPosition as J } from "../composables.js";
6
+ import { useChartInstance as Q, ThemeKey as Y, InfoBarAnchorKey as Z } from "../context.js";
7
+ const ee = {
8
8
  key: 0,
9
9
  style: { display: "inline-flex", alignItems: "center", gap: "4px" }
10
- }, ee = {
10
+ }, te = {
11
11
  key: 1,
12
12
  style: { display: "inline-flex", alignItems: "center", gap: "3px" }
13
- }, te = {
13
+ }, ae = {
14
14
  key: 2,
15
15
  style: { display: "inline-flex", alignItems: "center", gap: "3px" }
16
- }, se = /* @__PURE__ */ W({
16
+ }, ue = /* @__PURE__ */ T({
17
17
  __name: "InfoBar",
18
18
  props: {
19
19
  sort: {},
20
20
  format: { type: Function }
21
21
  },
22
- setup(z) {
23
- const b = z, k = i(() => b.sort ?? "none"), d = i(
24
- () => b.format ?? ((a, _) => _ === "volume" ? X(a) : q(a))
25
- ), u = J(), y = G(u), o = B(Q), g = B(Y);
22
+ setup(E) {
23
+ const k = E, C = s(() => k.sort ?? "none"), d = s(
24
+ () => k.format ?? ((a, _) => _ === "volume" ? q(a) : G(a))
25
+ ), n = Q(), g = J(n), o = B(Y), x = B(Z);
26
26
  if (!o)
27
27
  throw new Error("<InfoBar> must be used within <ChartContainer>: missing ThemeKey.");
28
- if (!g)
28
+ if (!x)
29
29
  throw new Error("<InfoBar> must be used within <ChartContainer>: missing InfoBarAnchorKey.");
30
- const h = N(0), C = () => {
30
+ const h = W(0), y = () => {
31
31
  h.value++;
32
32
  };
33
- O(() => {
34
- u.on("overlayChange", C), u.getSeriesIds().length > 0 && h.value++;
35
- }), T(() => {
36
- u.off("overlayChange", C);
33
+ N(() => {
34
+ n.on("overlayChange", y), n.on("seriesFrame", y), n.getSeriesIds().length > 0 && h.value++;
35
+ }), R(() => {
36
+ n.off("overlayChange", y), n.off("seriesFrame", y);
37
37
  });
38
- const x = i(() => {
38
+ const b = s(() => {
39
39
  h.value;
40
- const a = y.value;
41
- return a === null ? null : M(u, { time: a.time, sort: k.value, cacheKey: "infobar-hover" });
42
- }), E = i(() => (h.value, P(u, { sort: k.value, cacheKey: "infobar-last" }))), m = i(() => x.value !== null && x.value.length > 0), c = i(
43
- () => m.value ? x.value : E.value
44
- ), H = i(() => u.getDataInterval()), S = i(() => c.value.length === 0 ? 0 : m.value && y.value ? y.value.time : Math.max(...c.value.map((a) => a.data.time))), K = A(), w = i(() => typeof K.default == "function");
40
+ const a = g.value;
41
+ return a === null ? null : P(n, { time: a.time, sort: C.value, cacheKey: "infobar-hover" });
42
+ }), H = s(() => (h.value, $(n, { sort: C.value, cacheKey: "infobar-last" }))), v = s(() => b.value !== null && b.value.length > 0), c = s(
43
+ () => v.value ? b.value : H.value
44
+ ), K = s(() => (h.value, n.getDataInterval())), S = s(() => c.value.length === 0 ? 0 : v.value && g.value ? g.value.time : Math.max(...c.value.map((a) => a.data.time))), V = A(), w = s(() => typeof V.default == "function");
45
45
  function I(a) {
46
46
  return "open" in a;
47
47
  }
48
- function V(a) {
48
+ function z(a) {
49
49
  return "high" in a && !I(a);
50
50
  }
51
- return (a, _) => t(g) && t(o) && c.value.length > 0 ? (n(), R($, {
51
+ return (a, _) => t(x) && t(o) && c.value.length > 0 ? (l(), D(M, {
52
52
  key: 0,
53
- to: t(g)
53
+ to: t(x)
54
54
  }, [
55
- l("div", {
55
+ r("div", {
56
56
  "data-tooltip-legend": "",
57
- style: r(
57
+ style: i(
58
58
  w.value ? {
59
59
  display: "flex",
60
60
  alignItems: "center",
@@ -62,7 +62,7 @@ const Z = {
62
62
  fontSize: t(o).typography.fontSize + "px",
63
63
  fontFamily: t(o).typography.fontFamily,
64
64
  fontVariantNumeric: "tabular-nums",
65
- opacity: m.value ? 1 : 0.6,
65
+ opacity: v.value ? 1 : 0.6,
66
66
  transition: "opacity 0.2s ease",
67
67
  pointerEvents: "none"
68
68
  } : {
@@ -75,57 +75,57 @@ const Z = {
75
75
  fontSize: t(o).typography.fontSize + "px",
76
76
  fontFamily: t(o).typography.fontFamily,
77
77
  fontVariantNumeric: "tabular-nums",
78
- opacity: m.value ? 1 : 0.6,
78
+ opacity: v.value ? 1 : 0.6,
79
79
  transition: "opacity 0.2s ease",
80
80
  pointerEvents: "none"
81
81
  }
82
82
  )
83
83
  }, [
84
- w.value ? D(a.$slots, "default", {
84
+ w.value ? O(a.$slots, "default", {
85
85
  key: 0,
86
86
  snapshots: c.value,
87
87
  time: S.value,
88
- isHover: m.value
89
- }) : (n(), s(f, { key: 1 }, [
90
- l("span", {
91
- style: r({ color: t(o).axis.textColor, marginRight: "2px" })
92
- }, p(t(j)(t(u), { time: S.value, snapshots: c.value, interval: H.value })), 5),
93
- (n(!0), s(f, null, F(c.value, (e) => (n(), s(f, {
88
+ isHover: v.value
89
+ }) : (l(), u(m, { key: 1 }, [
90
+ r("span", {
91
+ style: i({ color: t(o).axis.textColor, marginRight: "2px" })
92
+ }, p(t(j)(t(n), { time: S.value, snapshots: c.value, interval: K.value })), 5),
93
+ (l(!0), u(m, null, F(c.value, (e) => (l(), u(m, {
94
94
  key: e.id
95
95
  }, [
96
- I(e.data) ? (n(), s("span", Z, [
97
- (n(!0), s(f, null, F([
96
+ I(e.data) ? (l(), u("span", ee, [
97
+ (l(!0), u(m, null, F([
98
98
  { label: "O", field: "open", val: e.data.open },
99
99
  { label: "H", field: "high", val: e.data.high },
100
100
  { label: "L", field: "low", val: e.data.low },
101
101
  { label: "C", field: "close", val: e.data.close }
102
- ], (v) => (n(), s(f, {
103
- key: v.label
102
+ ], (f) => (l(), u(m, {
103
+ key: f.label
104
104
  }, [
105
- l("span", {
106
- style: r({ color: t(o).axis.textColor, opacity: 0.5, marginLeft: "5px" })
107
- }, p(v.label), 5),
108
- l("span", {
109
- style: r({
110
- color: t(U)(
105
+ r("span", {
106
+ style: i({ color: t(o).axis.textColor, opacity: 0.5, marginLeft: "5px" })
107
+ }, p(f.label), 5),
108
+ r("span", {
109
+ style: i({
110
+ color: t(X)(
111
111
  e.data.close >= e.data.open ? t(o).candlestick.up.body : t(o).candlestick.down.body
112
112
  ),
113
113
  fontWeight: 500,
114
114
  marginLeft: "2px"
115
115
  })
116
- }, p(d.value(v.val, v.field)), 5)
116
+ }, p(d.value(f.val, f.field)), 5)
117
117
  ], 64))), 128)),
118
- e.data.volume != null ? (n(), s(f, { key: 0 }, [
119
- l("span", {
120
- style: r({ color: t(o).axis.textColor, opacity: 0.5, marginLeft: "5px" })
118
+ e.data.volume != null ? (l(), u(m, { key: 0 }, [
119
+ r("span", {
120
+ style: i({ color: t(o).axis.textColor, opacity: 0.5, marginLeft: "5px" })
121
121
  }, "V", 4),
122
- l("span", {
123
- style: r({ color: t(o).axis.textColor, fontWeight: 500, marginLeft: "2px" })
122
+ r("span", {
123
+ style: i({ color: t(o).axis.textColor, fontWeight: 500, marginLeft: "2px" })
124
124
  }, p(d.value(e.data.volume, "volume")), 5)
125
125
  ], 64)) : L("", !0)
126
- ])) : V(e.data) ? (n(), s("span", ee, [
127
- l("span", {
128
- style: r({
126
+ ])) : z(e.data) ? (l(), u("span", te, [
127
+ r("span", {
128
+ style: i({
129
129
  width: "6px",
130
130
  height: "6px",
131
131
  borderRadius: "1px",
@@ -133,12 +133,12 @@ const Z = {
133
133
  flexShrink: 0
134
134
  })
135
135
  }, null, 4),
136
- l("span", {
137
- style: r({ color: e.color, fontWeight: 500 })
136
+ r("span", {
137
+ style: i({ color: e.color, fontWeight: 500 })
138
138
  }, p(d.value(e.data.low, "low")) + " – " + p(d.value(e.data.high, "high")), 5)
139
- ])) : (n(), s("span", te, [
140
- l("span", {
141
- style: r({
139
+ ])) : (l(), u("span", ae, [
140
+ r("span", {
141
+ style: i({
142
142
  width: "6px",
143
143
  height: "6px",
144
144
  borderRadius: "50%",
@@ -146,9 +146,9 @@ const Z = {
146
146
  flexShrink: 0
147
147
  })
148
148
  }, null, 4),
149
- l("span", {
150
- style: r({ color: e.color, fontWeight: 500 })
151
- }, p(d.value(e.data.value, "value")), 5)
149
+ r("span", {
150
+ style: i({ color: e.color, fontWeight: 500 })
151
+ }, p(t(U)(e, (f) => d.value(f, "value"))), 5)
152
152
  ]))
153
153
  ], 64))), 128))
154
154
  ], 64))
@@ -157,5 +157,5 @@ const Z = {
157
157
  }
158
158
  });
159
159
  export {
160
- se as default
160
+ ue as default
161
161
  };
@@ -1,4 +1,4 @@
1
- import { defineComponent as _, ref as b, onMounted as g, computed as c, openBlock as o, createElementBlock as l, Fragment as r, renderList as f, createElementVNode as m, normalizeStyle as k, toDisplayString as p } from "vue";
1
+ import { defineComponent as k, ref as f, onMounted as N, computed as m, watch as I, openBlock as a, createElementBlock as l, Fragment as r, renderList as d, createElementVNode as y, normalizeStyle as w, toDisplayString as v } from "vue";
2
2
  const x = { style: {
3
3
  display: "inline-flex",
4
4
  fontVariantNumeric: "tabular-nums",
@@ -14,7 +14,7 @@ const x = { style: {
14
14
  }, F = {
15
15
  key: 1,
16
16
  style: { display: "inline-block" }
17
- }, w = /* @__PURE__ */ _({
17
+ }, S = /* @__PURE__ */ k({
18
18
  __name: "NumberFlow",
19
19
  props: {
20
20
  value: {},
@@ -22,48 +22,57 @@ const x = { style: {
22
22
  locale: { default: "en-US" },
23
23
  spinDuration: { default: 350 }
24
24
  },
25
- setup(a) {
26
- const s = a, i = b(!1);
27
- g(() => {
25
+ setup(h) {
26
+ const o = h, i = f(!1);
27
+ N(() => {
28
28
  i.value = !0;
29
29
  });
30
- const d = c(() => {
31
- const t = s.format;
32
- if (typeof t == "function") return t;
33
- const n = new Intl.NumberFormat(s.locale, typeof t == "object" ? t : void 0);
34
- return (e) => n.format(e);
35
- }), y = c(() => {
36
- const t = d.value(s.value), n = [];
37
- for (const e of t)
38
- e >= "0" && e <= "9" ? n.push({ type: "digit", value: e }) : n.push({ type: "symbol", value: e });
30
+ const u = m(() => {
31
+ const e = o.format;
32
+ if (typeof e == "function") return e;
33
+ const n = new Intl.NumberFormat(o.locale, typeof e == "object" ? e : void 0);
34
+ return (t) => n.format(t);
35
+ }), _ = m(() => {
36
+ const e = u.value(o.value), n = [];
37
+ for (const t of e)
38
+ t >= "0" && t <= "9" ? n.push({ type: "digit", value: t }) : n.push({ type: "symbol", value: t });
39
39
  return n;
40
- }), v = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
41
- return (t, n) => (o(), l("span", x, [
42
- (o(!0), l(r, null, f(y.value, (e, h) => (o(), l(r, { key: h }, [
43
- e.type === "digit" ? (o(), l("span", D, [
44
- m("span", {
45
- style: k({
40
+ }), s = f(o.spinDuration);
41
+ let c = Number.NEGATIVE_INFINITY;
42
+ I(
43
+ () => u.value(o.value),
44
+ () => {
45
+ const e = performance.now(), n = e - c < o.spinDuration;
46
+ c = e, s.value = n ? 0 : o.spinDuration;
47
+ }
48
+ );
49
+ const b = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
50
+ return (e, n) => (a(), l("span", x, [
51
+ (a(!0), l(r, null, d(_.value, (t, g) => (a(), l(r, { key: g }, [
52
+ t.type === "digit" ? (a(), l("span", D, [
53
+ y("span", {
54
+ style: w({
46
55
  display: "flex",
47
56
  flexDirection: "column",
48
- transform: "translateY(" + -parseInt(e.value) * 1.2 + "em)",
49
- transition: i.value ? "transform " + a.spinDuration + "ms cubic-bezier(0.16, 1, 0.3, 1)" : "none"
57
+ transform: "translateY(" + -parseInt(t.value) * 1.2 + "em)",
58
+ transition: i.value && s.value > 0 ? "transform " + s.value + "ms cubic-bezier(0.16, 1, 0.3, 1)" : "none"
50
59
  })
51
60
  }, [
52
- (o(), l(r, null, f(v, (u) => m("span", {
53
- key: u,
61
+ (a(), l(r, null, d(b, (p) => y("span", {
62
+ key: p,
54
63
  style: {
55
64
  display: "flex",
56
65
  alignItems: "center",
57
66
  justifyContent: "center",
58
67
  height: "1.2em"
59
68
  }
60
- }, p(u), 1)), 64))
69
+ }, v(p), 1)), 64))
61
70
  ], 4)
62
- ])) : (o(), l("span", F, p(e.value), 1))
71
+ ])) : (a(), l("span", F, v(t.value), 1))
63
72
  ], 64))), 128))
64
73
  ]));
65
74
  }
66
75
  });
67
76
  export {
68
- w as default
77
+ S as default
69
78
  };