@wick-charts/vue 0.4.1 → 0.4.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.
package/README.md CHANGED
@@ -63,9 +63,9 @@ Tree-shaken React scenarios via `pnpm size` (esbuild, minified, browser target,
63
63
 
64
64
  | Scenario | Raw | Gzip | Brotli |
65
65
  |---|---:|---:|---:|
66
- | Candlestick only | 165.2 kB | 49.5 kB | 42.3 kB |
67
- | Line only | 165.3 kB | 49.5 kB | 42.4 kB |
68
- | Full React | 183.3 kB | 54.6 kB | 46.5 kB |
66
+ | Candlestick only | 174.1 kB | 52.4 kB | 44.8 kB |
67
+ | Line only | 174.1 kB | 52.5 kB | 44.8 kB |
68
+ | Full React | 191.2 kB | 57.4 kB | 49.0 kB |
69
69
 
70
70
  ## Migration
71
71
 
package/dist/index.d.ts CHANGED
@@ -815,6 +815,41 @@ export declare const ayuMirage: ThemePreset;
815
815
  */
816
816
  declare type BarEntryAnimation = 'none' | 'fade' | 'grow' | 'slide' | 'fade-grow';
817
817
 
818
+ /** Post-transform bitmap rectangle a bar painter fills. */
819
+ declare interface BarGeometry {
820
+ x: number;
821
+ y: number;
822
+ width: number;
823
+ height: number;
824
+ /** The edge the bar grows from — the zero line, or the segment's own base. */
825
+ baselineY: number;
826
+ }
827
+
828
+ /** Arguments handed to a {@link BarPainter} once per bar / stacked segment. */
829
+ export declare interface BarPaintArgs {
830
+ geom: BarGeometry;
831
+ /** Semantic fill color — the legend / tooltip source of truth. */
832
+ color: string;
833
+ /**
834
+ * Free-end-aware corner mask. The renderer computed this from the draw mode
835
+ * (single / overlap / stacked-positive / stacked-negative / percent). A square
836
+ * bar arrives as all-false.
837
+ */
838
+ corners: CornerMask;
839
+ /** Resolved, pre-clamped bitmap radius. `0` means square. */
840
+ radius: number;
841
+ /**
842
+ * Entrance progress 0→1; advisory only — `geom` is already transformed by it.
843
+ * Forced to `1` when `isProjected` (a forecast bar doesn't "arrive").
844
+ */
845
+ progress: number;
846
+ /** Ghost / forecast flag derived from the series' `projectedFrom`. */
847
+ isProjected: boolean;
848
+ }
849
+
850
+ /** Paints one bar / stacked segment. Owns its fill — it calls `ctx.fill()`. */
851
+ export declare type BarPainter = (env: PaintEnv, args: BarPaintArgs) => void;
852
+
818
853
  export declare const BarSeries: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
819
854
 
820
855
  /** Visual options for a bar series. */
@@ -874,6 +909,33 @@ export declare interface BarSeriesOptions {
874
909
  * disable that wins over this field.
875
910
  */
876
911
  smoothMs?: number | false;
912
+ /**
913
+ * Free-end corner radius in CSS pixels. Default: `4`. `0` is byte-identical to
914
+ * the pre-rounding square output. The radius is clamped to half the smaller
915
+ * bar dimension, so thin bars / sub-radius segments degrade to flat.
916
+ *
917
+ * The renderer decides which edge is "free" per draw mode — a positive bar
918
+ * rounds its top, a negative bar its bottom, and in a stack only the topmost
919
+ * (or bottommost) segment per column rounds, interior segments stay square.
920
+ * `anchor` is orthogonal: rounding operates on the already-offset rect.
921
+ */
922
+ cornerRadius?: number;
923
+ /**
924
+ * Custom bar painter — a raw `BarPainter` function that owns the bar fill.
925
+ * Leave unset for the built-in rounded fill (driven by `cornerRadius`). Read
926
+ * fresh each frame; a new function reference is honored on the next render
927
+ * regardless of wrapper change-detection. Keep it a stable reference (module
928
+ * scope or `useCallback`) so the wrapper diffs it cleanly. A throw falls back
929
+ * to the default fill.
930
+ */
931
+ barPainter?: BarPainter;
932
+ /**
933
+ * Time (epoch ms) at/after which bars are flagged as projected / forecast
934
+ * "ghost" bars. The default painter fills those with a translucent derivative
935
+ * of their color; projected bars also skip the entrance transform so the ghost
936
+ * never double-fades. Omitted: no projected bars.
937
+ */
938
+ projectedFrom?: number;
877
939
  }
878
940
 
879
941
  /**
@@ -920,6 +982,40 @@ export declare interface BuildLastSnapshotsArgs {
920
982
  cacheKey: string;
921
983
  }
922
984
 
985
+ /** Post-transform bitmap rectangle a candle-body painter fills. */
986
+ declare interface CandleGeometry {
987
+ x: number;
988
+ y: number;
989
+ width: number;
990
+ height: number;
991
+ }
992
+
993
+ /** Arguments handed to a {@link CandlePainter} once per candle body. */
994
+ export declare interface CandlePaintArgs {
995
+ geom: CandleGeometry;
996
+ /**
997
+ * Engine-resolved fillStyle — the 2-stop gradient when the body color is a
998
+ * `[top, bottom]` tuple AND the body is tall enough, else the flat color. It
999
+ * is ALSO pre-set on `ctx.fillStyle`, so a painter that ignores this field
1000
+ * still fills correctly. The painter MUST NOT call `createLinearGradient` —
1001
+ * the ≤2px collapse and gradient build already happened upstream.
1002
+ */
1003
+ fillStyle: string | CanvasGradient;
1004
+ /** Representative flat color (the gradient's top stop). For derived shades. */
1005
+ color: string;
1006
+ /** All-true for candles (no baseline); the radius is clamped per element. */
1007
+ corners: CornerMask;
1008
+ /** Resolved, pre-clamped bitmap radius. `0` means square. */
1009
+ radius: number;
1010
+ /** Entrance progress 0→1; advisory only — `geom` is already transformed. */
1011
+ progress: number;
1012
+ /** `close >= open`. */
1013
+ isBullish: boolean;
1014
+ }
1015
+
1016
+ /** Paints one candle body. Owns its fill. Never re-creates the gradient. */
1017
+ export declare type CandlePainter = (env: PaintEnv, args: CandlePaintArgs) => void;
1018
+
923
1019
  /**
924
1020
  * `body` shape encodes the fill mode: a single color renders flat; a
925
1021
  * `[top, bottom]` tuple renders a 2-stop vertical gradient. Use
@@ -1003,6 +1099,24 @@ export declare interface CandlestickSeriesOptions {
1003
1099
  * a hard disable that wins over this field.
1004
1100
  */
1005
1101
  smoothMs?: number | false;
1102
+ /**
1103
+ * Body corner radius in CSS pixels, applied to all four corners (a candle
1104
+ * body has no baseline). Default: `3`. `0` is byte-identical to the prior
1105
+ * square output. Clamped to half the smaller body dimension, so dojis and
1106
+ * ≤2px bodies degrade to flat. The `[top, bottom]` gradient is preserved —
1107
+ * the painter fills with the engine-resolved gradient and never rebuilds it.
1108
+ */
1109
+ cornerRadius?: number;
1110
+ /**
1111
+ * Custom candle-body painter — a raw `CandlePainter` function that owns the
1112
+ * body fill. Leave unset for the built-in rounded fill (driven by
1113
+ * `cornerRadius`). Read fresh each frame; a new reference is honored on the
1114
+ * next render regardless of wrapper change-detection. Keep it a stable
1115
+ * reference (module scope or `useCallback`) so the wrapper diffs it cleanly.
1116
+ * A throw falls back to the default fill. The wick and volume histogram are
1117
+ * unaffected.
1118
+ */
1119
+ candlePainter?: CandlePainter;
1006
1120
  }
1007
1121
 
1008
1122
  export declare const catppuccin: ThemePreset;
@@ -1664,6 +1778,18 @@ export declare interface ChartTheme {
1664
1778
 
1665
1779
  export declare function computeTooltipPosition(args: TooltipPositionArgs): TooltipPosition;
1666
1780
 
1781
+ /**
1782
+ * Which corners a rounded-rect path rounds. A `false` corner is drawn square.
1783
+ * The RENDERER owns this decision (it knows the stack / overlap / percent mode);
1784
+ * a painter consumes the mask verbatim and never infers which edge is free.
1785
+ */
1786
+ export declare interface CornerMask {
1787
+ tl: boolean;
1788
+ tr: boolean;
1789
+ br: boolean;
1790
+ bl: boolean;
1791
+ }
1792
+
1667
1793
  /**
1668
1794
  * Build a complete {@link ThemePreset} from a partial config.
1669
1795
  * Only `background` is required — everything else is derived from it.
@@ -1684,6 +1810,9 @@ export declare interface CrosshairPosition {
1684
1810
  y: number;
1685
1811
  }
1686
1812
 
1813
+ /** Path-shape selector for {@link tracePath}. */
1814
+ export declare type CurveKind = 'straight' | 'smooth' | 'stepped';
1815
+
1687
1816
  export declare function detectInterval(times: number[]): number;
1688
1817
 
1689
1818
  export declare const dracula: ThemePreset;
@@ -1717,6 +1846,19 @@ declare class EventEmitter<Events = Record<string, Listener>> {
1717
1846
  removeAllListeners(): void;
1718
1847
  }
1719
1848
 
1849
+ /**
1850
+ * Fill a rounded rectangle with per-corner masking, using manual `arcTo` so the
1851
+ * output is deterministic and independent of `CanvasRenderingContext2D.roundRect`
1852
+ * availability. Self-contained: it opens its own path and fills with the current
1853
+ * `ctx.fillStyle`.
1854
+ *
1855
+ * Degenerate inputs — a sub-1px clamped radius, or a non-positive dimension —
1856
+ * fall back to a plain `fillRect`. That guarantees a tiny / 1px bar or a doji can
1857
+ * never emit a zero-radius or `NaN` `arcTo`, byte-matching the pre-rounding
1858
+ * output for those cases.
1859
+ */
1860
+ export declare function fillRoundedRect(ctx: CanvasRenderingContext2D, args: RoundedRectArgs): void;
1861
+
1720
1862
  /**
1721
1863
  * Compact notation for large magnitudes (K / M / B / T) with adaptive
1722
1864
  * precision for values below 1. Default decimal count for the compact
@@ -1830,6 +1972,45 @@ export declare const lightPink: ThemePreset;
1830
1972
  */
1831
1973
  declare type LineEntryAnimation = 'none' | 'grow' | 'fade';
1832
1974
 
1975
+ /** Arguments handed to a {@link LinePainter} once per finite run. */
1976
+ export declare interface LinePaintArgs {
1977
+ /**
1978
+ * One finite run of points — gaps already split runs, and the trailing-grow
1979
+ * endpoint is already appended. Read-only.
1980
+ */
1981
+ points: readonly LinePoint[];
1982
+ color: string;
1983
+ lineWidth: number;
1984
+ /**
1985
+ * `false` while building the stroke path; `true` while building the area-fill
1986
+ * top edge, before the engine appends the baseline `lineTo`×2 + `closePath` +
1987
+ * `fill`.
1988
+ */
1989
+ closing: boolean;
1990
+ /**
1991
+ * `true` while the trailing endpoint is an eased, frame-moving point (the
1992
+ * 'grow' entrance). A smooth builder MUST degrade the in-flight last segment to
1993
+ * a straight `lineTo` (only the settled run is curve-fit) so the head can't
1994
+ * wobble or overshoot while it glides.
1995
+ */
1996
+ grew: boolean;
1997
+ }
1998
+
1999
+ /**
2000
+ * Builds the path for one finite run. MUST issue only
2001
+ * `moveTo` / `lineTo` / `bezierCurveTo` / `quadraticCurveTo` onto `env.ctx`, and
2002
+ * MUST NOT call `beginPath` / `stroke` / `fill` / `closePath` — the engine wraps
2003
+ * the builder so the SAME path drives both the stroke and the baseline-closed
2004
+ * area polygon.
2005
+ */
2006
+ export declare type LinePainter = (env: PaintEnv, args: LinePaintArgs) => void;
2007
+
2008
+ /** A single bitmap-space point on a line run. */
2009
+ declare interface LinePoint {
2010
+ x: number;
2011
+ y: number;
2012
+ }
2013
+
1833
2014
  export declare const LineSeries: DefineComponent<__VLS_Props_4, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props_4> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
1834
2015
 
1835
2016
  /** Visual options for a line series. */
@@ -1918,6 +2099,26 @@ export declare interface LineSeriesOptions {
1918
2099
  * disable that wins over this field.
1919
2100
  */
1920
2101
  smoothMs?: number | false;
2102
+ /**
2103
+ * Declarative line smoothing. Default: `'straight'` (zero visual change —
2104
+ * the prior polyline). Resolves to a shipped built-in path builder inside the
2105
+ * renderer and drives the stroke, the area fill, and stacked slices from one
2106
+ * path:
2107
+ * - `'straight'` — plain polyline.
2108
+ * - `'smooth'` — Fritsch–Carlson monotone cubic (non-overshooting, so it stays
2109
+ * inside an area fill that closes to a baseline).
2110
+ * - `'stepped'` — horizontal-then-vertical step at each sample.
2111
+ */
2112
+ curve?: 'straight' | 'smooth' | 'stepped';
2113
+ /**
2114
+ * Custom line path builder — a raw `LinePainter` function. Overrides `curve`,
2115
+ * applied per finite run to both the stroke and the area-fill top edge. Read
2116
+ * fresh each frame; keep it a stable reference so the wrapper diffs it cleanly.
2117
+ * A throw falls back to the straight builder. Stacked mode uses the `curve`
2118
+ * kind for gap-free interior tiling, so a custom `linePainter` there falls back
2119
+ * to `'straight'`.
2120
+ */
2121
+ linePainter?: LinePainter;
1921
2122
  }
1922
2123
 
1923
2124
  declare type Listener = (...args: any[]) => void;
@@ -2048,6 +2249,21 @@ export declare type OHLCInput = Omit<OHLCData, 'time'> & {
2048
2249
 
2049
2250
  export declare const oneDarkPro: ThemePreset;
2050
2251
 
2252
+ /**
2253
+ * Engine context shared by every painter. `ctx.globalAlpha` is ALREADY composed
2254
+ * (layer × series × entrance fade) by the renderer, and every geometry handed to
2255
+ * a painter is already post-transform. Painters MUST NOT mutate `globalAlpha`
2256
+ * and MUST NOT re-run an entrance transform.
2257
+ */
2258
+ export declare interface PaintEnv {
2259
+ ctx: CanvasRenderingContext2D;
2260
+ theme: ChartTheme;
2261
+ /** Horizontal device-pixel ratio — scale your own CSS-px radii / insets by this. */
2262
+ horizontalPixelRatio: number;
2263
+ /** Vertical device-pixel ratio. */
2264
+ verticalPixelRatio: number;
2265
+ }
2266
+
2051
2267
  export declare const panda: ThemePreset;
2052
2268
 
2053
2269
  /**
@@ -2355,6 +2571,27 @@ declare interface RetargetOptions {
2355
2571
 
2356
2572
  export declare const rosePineDawn: ThemePreset;
2357
2573
 
2574
+ /** DEFAULT bar painter (registered as `'rounded'`). Trusts the engine-supplied
2575
+ * `corners` / `radius` / `isProjected`; a projected bar fills with a translucent
2576
+ * derivative of its color instead of mutating `globalAlpha`. */
2577
+ export declare const roundedBarFill: BarPainter;
2578
+
2579
+ /** DEFAULT candle-body painter (registered as `'rounded'`). Fills with the
2580
+ * engine-resolved `fillStyle` (gradient or flat) and never rebuilds a gradient. */
2581
+ export declare const roundedCandleFill: CandlePainter;
2582
+
2583
+ /** Arguments for {@link fillRoundedRect}. */
2584
+ export declare interface RoundedRectArgs {
2585
+ x: number;
2586
+ y: number;
2587
+ width: number;
2588
+ height: number;
2589
+ /** Pre-resolved bitmap radius applied to masked corners. */
2590
+ radius: number;
2591
+ /** Which corners to round; unmasked corners are square. */
2592
+ corners: CornerMask;
2593
+ }
2594
+
2358
2595
  export declare const sandDune: ThemePreset;
2359
2596
 
2360
2597
  /**
@@ -2394,6 +2631,10 @@ declare interface Size {
2394
2631
 
2395
2632
  export declare type SliceInfo = HoverInfo;
2396
2633
 
2634
+ /** `curve: 'smooth'` — monotone cubic. The in-flight last segment stays straight
2635
+ * while the trailing endpoint is growing so the head can't wobble / overshoot. */
2636
+ export declare const smoothCurve: LinePainter;
2637
+
2397
2638
  /** Sort order applied to a snapshot list by the helper. */
2398
2639
  export declare type SnapshotSort = 'none' | 'asc' | 'desc';
2399
2640
 
@@ -2402,6 +2643,13 @@ export declare const solarizedLight: ThemePreset;
2402
2643
  /** Stacking mode for bar/line series: off (overlap), normal (stacked), percent (100% stacked). */
2403
2644
  export declare type StackingMode = 'off' | 'normal' | 'percent';
2404
2645
 
2646
+ /** `curve: 'stepped'` — horizontal-then-vertical step at each sample. */
2647
+ export declare const steppedCurve: LinePainter;
2648
+
2649
+ /** DEFAULT line builder (`curve: 'straight'`). A plain polyline — identical to
2650
+ * the pre-feature stroke path. */
2651
+ export declare const straightCurve: LinePainter;
2652
+
2405
2653
  /**
2406
2654
  * Input config for {@link createTheme}. Mirrors the structure of {@link ChartTheme}
2407
2655
  * but everything is optional except `background`. Missing values are derived automatically.
@@ -2547,6 +2795,27 @@ export declare interface TooltipPositionArgs {
2547
2795
  offsetY?: number;
2548
2796
  }
2549
2797
 
2798
+ /**
2799
+ * Emit path commands for one run of points onto `env.ctx`. Issues only
2800
+ * `moveTo` / `lineTo` / `bezierCurveTo`; it never opens or closes a path, so the
2801
+ * engine can wrap the same trace into both a stroke and a baseline-closed area
2802
+ * polygon. Takes the full {@link PaintEnv} (not the raw context) so a custom
2803
+ * painter can compose on it directly with the `(env, args)` it receives.
2804
+ */
2805
+ export declare function tracePath(env: PaintEnv, args: TracePathArgs): void;
2806
+
2807
+ /** Arguments for {@link tracePath}. */
2808
+ export declare interface TracePathArgs {
2809
+ points: readonly LinePoint[];
2810
+ kind: CurveKind;
2811
+ /**
2812
+ * When `true`, the final segment is drawn as a straight `lineTo` even for the
2813
+ * smooth kind — used while the trailing endpoint is mid-grow so the moving head
2814
+ * can't wobble or overshoot.
2815
+ */
2816
+ settledOnly: boolean;
2817
+ }
2818
+
2550
2819
  /**
2551
2820
  * Smoothing-curve contract. Implementations (`YRangeHermite`, `YRangeSpring`,
2552
2821
  * `RangeSnap` for Y; `VisibleRangeSpring`, `RangeSnap` for X) drive a value