@wick-charts/react 0.2.2 → 0.3.0

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/dist/index.d.ts CHANGED
@@ -69,6 +69,35 @@ declare interface AnimationsConfig {
69
69
  */
70
70
  declare type AnimationTime = number | false;
71
71
 
72
+ /**
73
+ * Build a 2-stop candle-body gradient around a single hex color — a lightened
74
+ * top stop and a darkened bottom stop. Presets use this to get a subtle
75
+ * vertical lift without hand-picking both ends.
76
+ *
77
+ * candlestick: { up: { body: autoGradient('#089981'), wick: '#089981' } }
78
+ *
79
+ * The input must be `#rrggbb`; other CSS color forms are returned as a flat
80
+ * `[color, color]` tuple because the lighten/darken math requires hex.
81
+ *
82
+ * The returned tuple carries the source color on a non-enumerable `source`
83
+ * property so {@link resolveCandlestickBodyColor} can recover it for scalar
84
+ * fallbacks (yLabel backgrounds, bands, volume tint) instead of picking the
85
+ * lightened top stop.
86
+ */
87
+ export declare function autoGradient(color: string): AutoGradientTuple;
88
+
89
+ /**
90
+ * Tuple returned by {@link autoGradient}. The non-enumerable `source` property
91
+ * carries the original canonical color so scalar-fallback consumers
92
+ * (yLabel backgrounds, bands, default wick, volume tint) can recover it via
93
+ * {@link resolveCandlestickBodyColor} instead of picking the lightened top
94
+ * stop. `JSON.stringify` drops the marker, which is fine because
95
+ * `themeToJson` serializes all dependent scalar fields explicitly.
96
+ */
97
+ declare type AutoGradientTuple = [string, string] & {
98
+ readonly source?: string;
99
+ };
100
+
72
101
  /**
73
102
  * Defines a bound for the Y axis.
74
103
  *
@@ -198,6 +227,16 @@ export declare interface BuildLastSnapshotsArgs {
198
227
  cacheKey: string;
199
228
  }
200
229
 
230
+ /**
231
+ * `body` shape encodes the fill mode: a single color renders flat; a
232
+ * `[top, bottom]` tuple renders a 2-stop vertical gradient. Use
233
+ * `autoGradient(color)` for the subtle lightened/darkened look.
234
+ */
235
+ declare interface CandlestickDirectionColors {
236
+ body: string | [string, string];
237
+ wick: string;
238
+ }
239
+
201
240
  /**
202
241
  * Entrance animation styles for candlesticks (shown when a new candle appears via `appendData`).
203
242
  * - `'none'` — no animation.
@@ -215,16 +254,10 @@ export declare function CandlestickSeries({ data, options, id: idProp }: Candles
215
254
  export declare interface CandlestickSeriesOptions {
216
255
  /** Display label shown in the tooltip. */
217
256
  label?: string;
218
- upColor: string;
219
- downColor: string;
220
- wickUpColor: string;
221
- wickDownColor: string;
257
+ up: CandlestickDirectionColors;
258
+ down: CandlestickDirectionColors;
222
259
  /** Width of candle body as a fraction of the available bar slot (0-1). */
223
260
  bodyWidthRatio: number;
224
- /** Apply a subtle vertical gradient to candle bodies. Default: true. */
225
- bodyGradient?: boolean;
226
- /** @deprecated Use {@link bodyGradient} instead. */
227
- candleGradient?: boolean;
228
261
  /**
229
262
  * Entrance animation style for newly appended candles. Style is specific to
230
263
  * the candlestick; there is no chart-level override for style — only for
@@ -680,12 +713,23 @@ export declare interface ChartTheme {
680
713
  color: string;
681
714
  style: 'solid' | 'dashed' | 'dotted';
682
715
  };
683
- /** OHLC candlestick body and wick colors. */
716
+ /**
717
+ * OHLC candlestick colors. `wick` defaults to `body` in {@link createTheme}
718
+ * when omitted, so most presets only need to set the body colors.
719
+ *
720
+ * `body` shape encodes the fill: a single color renders flat; a
721
+ * `[top, bottom]` tuple renders a 2-stop vertical gradient. Presets that
722
+ * want the subtle lightened/darkened look pass `autoGradient(color)`.
723
+ */
684
724
  candlestick: {
685
- upColor: string;
686
- downColor: string;
687
- wickUpColor: string;
688
- wickDownColor: string;
725
+ up: {
726
+ body: string | [string, string];
727
+ wick: string;
728
+ };
729
+ down: {
730
+ body: string | [string, string];
731
+ wick: string;
732
+ };
689
733
  };
690
734
  /** Default line series appearance including area gradient fill. */
691
735
  line: {
@@ -707,12 +751,27 @@ export declare interface ChartTheme {
707
751
  labelBackground: string;
708
752
  labelTextColor: string;
709
753
  };
710
- /** Axis tick label styling. */
754
+ /**
755
+ * Axis tick styling. `fontSize` and `textColor` are the shared defaults used
756
+ * for both X and Y, as well as non-axis label surfaces (legend, crosshair
757
+ * labels, sparkline ticks). Set `x` / `y` only when a specific axis needs to
758
+ * diverge.
759
+ */
711
760
  axis: {
761
+ fontSize: number;
712
762
  textColor: string;
763
+ x?: {
764
+ fontSize?: number;
765
+ textColor?: string;
766
+ };
767
+ y?: {
768
+ fontSize?: number;
769
+ textColor?: string;
770
+ };
713
771
  };
714
772
  /** Floating label shown at the current value level on the Y axis. */
715
773
  yLabel: {
774
+ fontSize: number;
716
775
  upBackground: string;
717
776
  downBackground: string;
718
777
  neutralBackground: string;
@@ -720,6 +779,7 @@ export declare interface ChartTheme {
720
779
  };
721
780
  /** Hover tooltip styling. */
722
781
  tooltip: {
782
+ fontSize: number;
723
783
  background: string;
724
784
  textColor: string;
725
785
  borderColor: string;
@@ -1392,6 +1452,36 @@ declare interface Rect {
1392
1452
  height: number;
1393
1453
  }
1394
1454
 
1455
+ /**
1456
+ * Resolve the effective font size for a given axis, falling back to the
1457
+ * shared `axis.fontSize` default when no per-axis override is set.
1458
+ *
1459
+ * Pass `'x'` or `'y'` for axis-specific surfaces (TimeAxis, YAxis). Omit the
1460
+ * argument for non-axis label surfaces that share the same size (Legend,
1461
+ * Crosshair label, Sparkline ticks).
1462
+ */
1463
+ export declare function resolveAxisFontSize(theme: ChartTheme, axis?: 'x' | 'y'): number;
1464
+
1465
+ /**
1466
+ * Resolve the effective text color for a given axis, falling back to the
1467
+ * shared `axis.textColor` default when no per-axis override is set.
1468
+ */
1469
+ export declare function resolveAxisTextColor(theme: ChartTheme, axis?: 'x' | 'y'): string;
1470
+
1471
+ /**
1472
+ * Pick a single flat color from a candlestick body that may be either a single
1473
+ * color or a `[top, bottom]` gradient tuple. Use this wherever a solid color
1474
+ * is needed — tooltip text, legend swatches, sparkline trend indicator,
1475
+ * yLabel backgrounds, volume tinting, etc.
1476
+ *
1477
+ * For tuples produced by `autoGradient(c)` the canonical `c` is preserved on
1478
+ * a non-enumerable `source` property and returned as-is — this prevents the
1479
+ * lightened top stop from silently replacing the candle's perceived color
1480
+ * across dependent UI. Plain user tuples without a source fall back to the
1481
+ * top stop.
1482
+ */
1483
+ export declare function resolveCandlestickBodyColor(body: string | [string, string]): string;
1484
+
1395
1485
  export declare const rosePineDawn: ThemePreset;
1396
1486
 
1397
1487
  export declare const sandDune: ThemePreset;
@@ -1493,7 +1583,10 @@ export declare interface ThemeConfig {
1493
1583
  chartGradient?: [string, string];
1494
1584
  typography?: Partial<ChartTheme['typography']>;
1495
1585
  grid?: Partial<ChartTheme['grid']>;
1496
- candlestick?: Partial<ChartTheme['candlestick']>;
1586
+ candlestick?: {
1587
+ up?: Partial<ChartTheme['candlestick']['up']>;
1588
+ down?: Partial<ChartTheme['candlestick']['down']>;
1589
+ };
1497
1590
  line?: Partial<ChartTheme['line']>;
1498
1591
  seriesColors?: string[];
1499
1592
  bands?: Partial<ChartTheme['bands']>;
@@ -1713,13 +1806,11 @@ export declare interface TooltipRenderContext {
1713
1806
  /** Sort order for multi-series tooltip values. */
1714
1807
  export declare type TooltipSort = 'none' | 'asc' | 'desc';
1715
1808
 
1716
- /** Font family and size tokens used across the chart. */
1809
+ /** Font family and base font size used across the chart. */
1717
1810
  export declare interface Typography {
1718
1811
  fontFamily: string;
1812
+ /** Base body font size — titles, infobar, pie tooltip/legend default to this. */
1719
1813
  fontSize: number;
1720
- axisFontSize: number;
1721
- yFontSize: number;
1722
- tooltipFontSize: number;
1723
1814
  }
1724
1815
 
1725
1816
  export declare function useChartInstance(): ChartInstance;