@wick-charts/vue 0.6.1 → 0.6.3

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 (52) hide show
  1. package/dist/ChartContainer.vue.js +43 -37
  2. package/dist/LineSeries.vue.js +2 -2
  3. package/dist/composables.js +39 -26
  4. package/dist/core/dist/animation/config.js +66 -64
  5. package/dist/core/dist/animation/intro-wave.js +19 -21
  6. package/dist/core/dist/animation/reduced-motion.js +6 -0
  7. package/dist/core/dist/axis/dom-labels.js +58 -45
  8. package/dist/core/dist/chart/badge-animator.js +15 -19
  9. package/dist/core/dist/chart/options.js +5 -5
  10. package/dist/core/dist/chart/scale-guards.js +26 -0
  11. package/dist/core/dist/chart/y-target.js +46 -19
  12. package/dist/core/dist/chart.js +752 -570
  13. package/dist/core/dist/components/crosshair.js +8 -8
  14. package/dist/core/dist/components/grid.js +28 -15
  15. package/dist/core/dist/components/marker.js +28 -28
  16. package/dist/core/dist/components/reference-line.js +16 -16
  17. package/dist/core/dist/interactions/handler.js +3 -2
  18. package/dist/core/dist/interactions/zoom.js +6 -5
  19. package/dist/core/dist/navigator/controller.js +43 -40
  20. package/dist/core/dist/perf/perf-hud.js +3 -3
  21. package/dist/core/dist/scales/log-scale.js +76 -0
  22. package/dist/core/dist/scales/tick-tracker.js +2 -2
  23. package/dist/core/dist/scales/x-scale.js +47 -32
  24. package/dist/core/dist/scales/y-scale.js +155 -38
  25. package/dist/core/dist/series/bar-intro.js +11 -11
  26. package/dist/core/dist/series/bar.js +299 -249
  27. package/dist/core/dist/series/base-multi-layer.js +100 -76
  28. package/dist/core/dist/series/candlestick.js +252 -249
  29. package/dist/core/dist/series/heatmap.js +16 -16
  30. package/dist/core/dist/series/line-intro.js +18 -18
  31. package/dist/core/dist/series/line.js +522 -424
  32. package/dist/core/dist/series/scale-stack.js +25 -0
  33. package/dist/core/dist/tooltip-position.js +5 -5
  34. package/dist/core/dist/utils/pixel-grid.js +10 -0
  35. package/dist/index.d.ts +279 -32
  36. package/dist/index.js +59 -57
  37. package/dist/ui/Crosshair.vue.js +14 -14
  38. package/dist/ui/HeatmapTooltip.vue.js +6 -6
  39. package/dist/ui/PieTooltip.vue.js +4 -4
  40. package/dist/ui/TimeAxis.vue.js +23 -22
  41. package/dist/ui/Tooltip.vue.js +71 -69
  42. package/dist/ui/YAxis.vue.js +25 -24
  43. package/dist/ui/YLabel.vue.js +50 -49
  44. package/package.json +2 -2
  45. package/src/ChartContainer.vue +20 -8
  46. package/src/composables.ts +35 -1
  47. package/src/index.ts +5 -0
  48. package/src/ui/Crosshair.vue +2 -2
  49. package/src/ui/TimeAxis.vue +7 -4
  50. package/src/ui/Tooltip.vue +4 -1
  51. package/src/ui/YAxis.vue +5 -3
  52. package/src/ui/YLabel.vue +3 -3
@@ -1,59 +1,72 @@
1
- import { resolveAxisTextColor as w, resolveAxisFontSize as A } from "../theme/resolve.js";
2
- const F = 0.01;
3
- function $(g) {
4
- const { chart: e, container: h, axis: r } = g, s = /* @__PURE__ */ new Map();
5
- let y = null;
6
- const m = r === "x" ? e.timeScale.tickTracker : e.yScale.tickTracker;
7
- function k() {
8
- return r === "x" ? e.timeScale.niceTickValues(e.getDataInterval()) : { ticks: e.yScale.niceTickValues(), tickInterval: 0 };
9
- }
10
- function p(t, o) {
11
- return r === "x" ? e.timeScale.formatX(t, o) : e.yScale.formatY(t);
12
- }
13
- function C(t, o) {
14
- if (r === "x") {
15
- t.style.left = `${e.timeScale.timeToX(o)}px`;
1
+ import { resolveAxisTextColor as I, resolveAxisFontSize as C } from "../theme/resolve.js";
2
+ import { clamp as P } from "../utils/math.js";
3
+ const V = 0.01;
4
+ function E(T) {
5
+ const { chart: e, container: w, axis: a } = T, r = /* @__PURE__ */ new Map();
6
+ let p = null, m = null;
7
+ const x = a === "x" ? e.timeScale.tickTracker : e.yScale.tickTracker;
8
+ function A() {
9
+ return a === "x" ? e.timeScale.niceTickValues(e.getDataInterval()) : { ticks: e.yScale.niceTickValues(), tickInterval: 0 };
10
+ }
11
+ function S(t, o) {
12
+ return a === "x" ? e.timeScale.formatX(t, o) : e.yScale.formatY(t);
13
+ }
14
+ function $(t, o) {
15
+ if (a === "x") {
16
+ t.style.left = `${e.timeScale.timeToSnappedX(o)}px`;
16
17
  return;
17
18
  }
18
- t.style.top = `${e.yScale.valueToY(o)}px`;
19
+ t.style.top = `${e.yScale.valueToSnappedY(o)}px`;
20
+ }
21
+ function h(t, o) {
22
+ t.style.color = I(o, a), t.style.fontSize = `${C(o, a)}px`, t.style.fontFamily = o.typography.fontFamily;
23
+ }
24
+ function v(t, o) {
25
+ const i = o === "left" ? "left" : "right", n = o === "left" ? "right" : "left";
26
+ t.style[i] = "8px", t.style[n] = "";
19
27
  }
20
- function x(t, o) {
21
- t.style.color = w(o, r), t.style.fontSize = `${A(o, r)}px`, t.style.fontFamily = o.typography.fontFamily;
28
+ function F(t, o) {
29
+ const i = e.headerHeight;
30
+ if (a !== "y" || i <= 0 || e.yAxisPosition !== "left") return 1;
31
+ const n = C(o, a), y = e.yScale.valueToSnappedY(t) - n / 2;
32
+ return P((y - i + n) / n, 0, 1);
22
33
  }
23
- function T(t, o, u) {
34
+ function Y(t, o, i) {
24
35
  const n = document.createElement("span");
25
- return n.textContent = p(t, o), n.style.position = "absolute", n.style.userSelect = "none", x(n, u), n.style.willChange = "opacity", r === "x" ? (n.style.transform = "translateX(-50%)", n.style.whiteSpace = "nowrap") : (n.style.right = "8px", n.style.transform = "translateY(-50%)", n.style.fontVariantNumeric = "tabular-nums"), h.appendChild(n), n;
26
- }
27
- function l() {
28
- const t = e.getTheme(), o = t !== y;
29
- y = t;
30
- const { ticks: u, tickInterval: n } = k();
31
- m.setCurrentTicks(u);
32
- const { entries: d } = m.snapshot(), v = /* @__PURE__ */ new Set();
33
- for (const { value: a, opacity: f } of d) {
34
- if (f <= F) continue;
35
- v.add(a);
36
- let i = s.get(a);
37
- if (i === void 0)
38
- i = T(a, n, t), s.set(a, i);
36
+ return n.textContent = S(t, o), n.style.position = "absolute", n.style.userSelect = "none", h(n, i), n.style.willChange = "opacity", a === "x" ? (n.style.transform = "translateX(-50%)", n.style.whiteSpace = "nowrap") : (v(n, e.yAxisPosition), n.style.transform = "translateY(-50%)", n.style.fontVariantNumeric = "tabular-nums"), w.appendChild(n), n;
37
+ }
38
+ function c() {
39
+ const t = e.getTheme(), o = t !== p;
40
+ p = t;
41
+ const i = e.yAxisPosition, n = a === "y" && i !== m;
42
+ m = i;
43
+ const { ticks: y, tickInterval: g } = A();
44
+ x.setCurrentTicks(y);
45
+ const { entries: b } = x.snapshot(), k = /* @__PURE__ */ new Set();
46
+ for (const { value: s, opacity: u } of b) {
47
+ if (u <= V) continue;
48
+ k.add(s);
49
+ let l = r.get(s);
50
+ if (l === void 0)
51
+ l = Y(s, g, t), r.set(s, l);
39
52
  else {
40
- const S = p(a, n);
41
- i.textContent !== S && (i.textContent = S), o && x(i, t);
53
+ const d = S(s, g);
54
+ l.textContent !== d && (l.textContent = d), o && h(l, t), n && v(l, i);
42
55
  }
43
- C(i, a), i.style.opacity = String(f);
56
+ $(l, s), l.style.opacity = String(u * F(s, t));
44
57
  }
45
- for (const [a, f] of s)
46
- v.has(a) || (f.remove(), s.delete(a));
58
+ for (const [s, u] of r)
59
+ k.has(s) || (u.remove(), r.delete(s));
47
60
  }
48
- function c() {
49
- e.getAnimationState().animating || l();
61
+ function f() {
62
+ e.getAnimationState().animating || c();
50
63
  }
51
- return l(), e.on("tickFrame", l), e.on("viewportChange", c), e.on("overlayChange", c), () => {
52
- e.off("tickFrame", l), e.off("viewportChange", c), e.off("overlayChange", c);
53
- for (const t of s.values()) t.remove();
54
- s.clear();
64
+ return c(), e.on("tickFrame", c), e.on("viewportChange", f), e.on("overlayChange", f), () => {
65
+ e.off("tickFrame", c), e.off("viewportChange", f), e.off("overlayChange", f);
66
+ for (const t of r.values()) t.remove();
67
+ r.clear();
55
68
  };
56
69
  }
57
70
  export {
58
- $ as mountAxisLabels
71
+ E as mountAxisLabels
59
72
  };
@@ -1,6 +1,6 @@
1
1
  import { ScalarSpring as g } from "../animation/scalar-spring.js";
2
- const r = 320, m = 0.15;
3
- class w {
2
+ const r = 320, V = 0.15;
3
+ class x {
4
4
  #t;
5
5
  #e;
6
6
  #i = !1;
@@ -8,11 +8,11 @@ class w {
8
8
  this.#t = new g(i), this.#e = i;
9
9
  }
10
10
  frame(i) {
11
- const { target: t, firstVisible: n, introFront: o, now: s, glide: u = !0, countUp: l = !0, reducedMotion: f = !1 } = i;
12
- if (f || !u && !l)
11
+ const { target: t, firstVisible: n, introFront: o, now: s, glide: u = !0, countUp: l = !0, reducedMotion: p = !1 } = i;
12
+ if (p || !u && !l)
13
13
  return this.#t.snap(t, { now: s }), this.#e = t, this.#i = !0, { positionValue: t, textValue: t, opacity: 1, animating: !1 };
14
14
  if (o < 1) {
15
- const h = n + (t - n) * o, a = l ? h : t;
15
+ const f = n + (t - n) * o, a = l ? f : t;
16
16
  return this.#t.snap(a, { now: s }), this.#e = a, this.#i = !0, { positionValue: a, textValue: a, opacity: this.#s(o), animating: !0 };
17
17
  }
18
18
  if (!this.#i)
@@ -22,35 +22,31 @@ class w {
22
22
  const c = i.settleMs ?? r;
23
23
  if (c <= 0)
24
24
  return this.#t.snap(t, { now: s }), this.#e = t, { positionValue: t, textValue: t, opacity: 1, animating: !1 };
25
- Math.abs(t - this.#e) > V && (this.#t.retarget(t, { now: s, settleMs: c }), this.#e = t);
26
- const p = this.#t.tick(s);
27
- return { positionValue: this.#t.current, textValue: t, opacity: 1, animating: p };
25
+ Math.abs(t - this.#e) > m && (this.#t.retarget(t, { now: s, settleMs: c }), this.#e = t);
26
+ const h = this.#t.tick(s);
27
+ return { positionValue: this.#t.current, textValue: t, opacity: 1, animating: h };
28
28
  }
29
29
  #s(i) {
30
- return i >= 1 ? 1 : d(i / m);
30
+ return i >= 1 ? 1 : d(i / V);
31
31
  }
32
32
  }
33
- const V = 1e-9;
33
+ const m = 1e-9;
34
34
  function d(e) {
35
35
  return e <= 0 ? 0 : e >= 1 ? 1 : e;
36
36
  }
37
- function x(e) {
37
+ function M(e) {
38
38
  return e === !1 ? { glide: !1, countUp: !1, settleMs: 0 } : e === void 0 || e === !0 ? { glide: !0, countUp: !0, settleMs: r } : {
39
39
  glide: e.glide ?? !0,
40
40
  countUp: e.countUp ?? !0,
41
41
  settleMs: e.settleMs ?? r
42
42
  };
43
43
  }
44
- function y() {
45
- return typeof matchMedia != "function" ? !1 : matchMedia("(prefers-reduced-motion: reduce)").matches;
46
- }
47
- function U(e, i, t) {
44
+ function y(e, i, t) {
48
45
  const { from: n } = e.getVisibleRange();
49
46
  return e.getStackedValueAtTime(i, n) ?? t;
50
47
  }
51
48
  export {
52
- w as BadgeAnimator,
53
- U as firstVisibleValue,
54
- y as prefersReducedMotion,
55
- x as resolveAnimate
49
+ x as BadgeAnimator,
50
+ y as firstVisibleValue,
51
+ M as resolveAnimate
56
52
  };
@@ -2,14 +2,14 @@ import { DEFAULT_MAX_VISIBLE_BARS as i, MIN_VISIBLE_BARS as r } from "./pan-zoom
2
2
  function n(t) {
3
3
  return t === void 0 || !Number.isFinite(t) || t <= 0 ? 0 : t;
4
4
  }
5
- function a(t) {
5
+ function l(t) {
6
6
  return {
7
7
  top: n(t?.top),
8
8
  right: t?.right === void 0 ? null : n(t.right),
9
- left: n(t?.left)
9
+ left: t?.left === void 0 ? null : n(t.left)
10
10
  };
11
11
  }
12
- function l(t) {
12
+ function a(t) {
13
13
  if (!t) return { monitor: null, ownsMonitor: !1, hud: null };
14
14
  if (typeof t != "object" || !("monitor" in t || "recordFrame" in t))
15
15
  throw new Error(
@@ -39,8 +39,8 @@ function m(t) {
39
39
  }
40
40
  export {
41
41
  u as isSameHorizontalPadding,
42
- a as resolveFade,
42
+ l as resolveFade,
43
43
  m as resolveMaxVisibleBars,
44
44
  f as resolvePadding,
45
- l as resolvePerfOptions
45
+ a as resolvePerfOptions
46
46
  };
@@ -0,0 +1,26 @@
1
+ function o(a) {
2
+ if (!(a.stacking !== "percent" || a.isPlottable(0)))
3
+ throw new Error(
4
+ `[wick-charts] Series '${a.seriesId}' uses stacking: 'percent', which this Y scale can't show — a 0–100% axis starts at 0, and the scale has no position for 0. Use a linear axis, or stacking: 'normal' / 'off'.`
5
+ );
6
+ }
7
+ function i(a) {
8
+ if (process.env.NODE_ENV === "production") return;
9
+ const { y: n, isPlottable: t } = a;
10
+ for (const e of ["min", "max"]) {
11
+ const s = n?.[e];
12
+ typeof s != "number" || t(s) || console.warn(
13
+ `[wick-charts] axis.y.${e} is ${s}, which the Y scale can't place — falling back to 'auto'. Use a bound inside the scale's domain.`
14
+ );
15
+ }
16
+ }
17
+ function r(a) {
18
+ process.env.NODE_ENV !== "production" && console.warn(
19
+ `[wick-charts] Series '${a.seriesId}' has values in view the Y scale can't place (e.g. ${a.value}; a log axis has no position for values ≤ 0). They are skipped — gaps in a line, no bar or candle. Filter or offset the data, or use a linear axis.`
20
+ );
21
+ }
22
+ export {
23
+ o as assertStackingFitsScale,
24
+ i as warnUnplottableBounds,
25
+ r as warnUnplottableValues
26
+ };
@@ -1,25 +1,52 @@
1
- import { isTimeSeriesRenderer as m } from "../series/types.js";
2
- function c(e, t, i) {
3
- let o = 1 / 0, a = -1 / 0;
4
- for (const n of t) {
5
- if (!n.visible || !m(n.renderer)) continue;
6
- const r = n.renderer.getValueRange(e.from, e.to);
7
- r && (r.max > a && (a = r.max), r.min < o && (o = r.min), i?.push(r.min, r.max));
1
+ import { isPlottableOn as c } from "../scales/y-scale.js";
2
+ import { isTimeSeriesRenderer as d } from "../series/types.js";
3
+ function b(n) {
4
+ const { targetVisible: a, series: t, allValues: o, plottable: r } = n, e = r ? { plottable: r } : void 0;
5
+ let s = 1 / 0, i = -1 / 0;
6
+ for (const l of t) {
7
+ if (!l.visible || !d(l.renderer)) continue;
8
+ const m = l.renderer.getValueRange(a.from, a.to, e);
9
+ m && (r && !r(m.max) || (m.max > i && (i = m.max), m.min < s && (!r || r(m.min)) && (s = m.min), o?.push(m.min, m.max)));
8
10
  }
9
- return o === 1 / 0 || a === -1 / 0 ? null : { min: o, max: a };
11
+ return i === -1 / 0 ? null : (s === 1 / 0 && (s = i), { min: s, max: i });
10
12
  }
11
- function p(e, t, i, o, a) {
12
- if (e === void 0 || e === "auto") return t;
13
- if (typeof e == "number") return e;
14
- if (typeof e == "function") return e(o);
15
- const n = String(e).match(/^([+-]?)\s*(\d+(?:\.\d+)?)\s*%$/);
16
- if (n) {
17
- const r = n[1] === "-" ? -1 : 1, s = parseFloat(n[2]) / 100, u = Math.abs(i - t) || Math.abs(t) || 1;
18
- return t + r * s * u * (a === "max" ? 1 : -1);
13
+ function w(n) {
14
+ const { raw: a, bounds: t, allValues: o, transform: r } = n;
15
+ if (r === null)
16
+ return {
17
+ min: u(t.min, a.min, a.max, o, "min"),
18
+ max: u(t.max, a.max, a.min, o, "max")
19
+ };
20
+ const e = { min: r.forward(a.min), max: r.forward(a.max) };
21
+ return {
22
+ min: f({ bound: t.min, raw: a, scaledRaw: e, allValues: o, side: "min", transform: r }),
23
+ max: f({ bound: t.max, raw: a, scaledRaw: e, allValues: o, side: "max", transform: r })
24
+ };
25
+ }
26
+ function f(n) {
27
+ const { bound: a, raw: t, scaledRaw: o, allValues: r, side: e, transform: s } = n, i = e === "min" ? "max" : "min";
28
+ if (typeof a == "string" && a !== "auto")
29
+ return u(a, o[e], o[i], [], e);
30
+ const l = u(a, t[e], t[i], r, e), m = c(s, l);
31
+ return s.forward(m ? l : t[e]);
32
+ }
33
+ function g(n, a) {
34
+ return a === null ? n : { min: a.inverse(n.min), max: a.inverse(n.max) };
35
+ }
36
+ function u(n, a, t, o, r) {
37
+ if (n === void 0 || n === "auto") return a;
38
+ if (typeof n == "number") return n;
39
+ if (typeof n == "function") return n(o);
40
+ const e = String(n).match(/^([+-]?)\s*(\d+(?:\.\d+)?)\s*%$/);
41
+ if (e) {
42
+ const s = e[1] === "-" ? -1 : 1, i = parseFloat(e[2]) / 100, l = Math.abs(t - a) || Math.abs(a) || 1;
43
+ return a + s * i * l * (r === "max" ? 1 : -1);
19
44
  }
20
- return t;
45
+ return a;
21
46
  }
22
47
  export {
23
- c as computeTargetYRange,
24
- p as resolveBound
48
+ b as computeTargetYRange,
49
+ g as fromScaleSpace,
50
+ u as resolveBound,
51
+ w as resolveYTarget
25
52
  };