@wick-charts/react 0.3.1 → 0.3.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/dist/index.d.ts CHANGED
@@ -110,7 +110,9 @@ export declare type AxisBound = 'auto' | number | string | ((values: number[]) =
110
110
 
111
111
  /** Grouped axis configuration for both axes. */
112
112
  export declare interface AxisConfig {
113
+ /** Y-axis configuration — width, bounds, and visibility of the value axis. */
113
114
  y?: YAxisConfig;
115
+ /** X-axis configuration — height and visibility of the time axis. */
114
116
  x?: XAxisConfig;
115
117
  }
116
118
 
@@ -134,6 +136,7 @@ export declare interface BarSeriesOptions {
134
136
  label?: string;
135
137
  /** One color per layer. */
136
138
  colors: string[];
139
+ /** Width of each bar as a fraction of the available bar slot (0–1). `1` = bars touch; `0.6` = roughly 60 % of the slot. Default: 0.7. */
137
140
  barWidthRatio: number;
138
141
  /** Stacking mode. Default: 'off'. */
139
142
  stacking: StackingMode;
@@ -175,6 +178,7 @@ export declare interface BarSeriesOptions {
175
178
  declare interface BarSeriesProps {
176
179
  /** Array of datasets — one per layer. A single-layer bar chart uses `[data]`. */
177
180
  data: TimePoint[][];
181
+ /** Visual options override — colours per layer, bar-width ratio, stacking, entrance animation, smoothing. */
178
182
  options?: Partial<BarSeriesOptions>;
179
183
  /** Stable series ID — same value across remounts. */
180
184
  id?: string;
@@ -233,7 +237,9 @@ export declare interface BuildLastSnapshotsArgs {
233
237
  * `autoGradient(color)` for the subtle lightened/darkened look.
234
238
  */
235
239
  declare interface CandlestickDirectionColors {
240
+ /** Body fill — single colour for flat, `[top, bottom]` tuple for a 2-stop vertical gradient. */
236
241
  body: string | [string, string];
242
+ /** Wick stroke colour. */
237
243
  wick: string;
238
244
  }
239
245
 
@@ -254,7 +260,9 @@ export declare function CandlestickSeries({ data, options, id: idProp }: Candles
254
260
  export declare interface CandlestickSeriesOptions {
255
261
  /** Display label shown in the tooltip. */
256
262
  label?: string;
263
+ /** Colours for bullish candles (close ≥ open). */
257
264
  up: CandlestickDirectionColors;
265
+ /** Colours for bearish candles (close < open). */
258
266
  down: CandlestickDirectionColors;
259
267
  /** Width of candle body as a fraction of the available bar slot (0-1). */
260
268
  bodyWidthRatio: number;
@@ -294,7 +302,9 @@ export declare interface CandlestickSeriesOptions {
294
302
  }
295
303
 
296
304
  declare interface CandlestickSeriesProps {
305
+ /** OHLC candles to render. Each element carries `time/open/high/low/close` and an optional `volume`. */
297
306
  data: OHLCInput[];
307
+ /** Visual options override — colours, body width, entrance animation, smoothing. Merged onto theme defaults. */
298
308
  options?: Partial<CandlestickSeriesOptions>;
299
309
  /** Stable series ID — same value across remounts. */
300
310
  id?: string;
@@ -325,16 +335,30 @@ declare interface ChartContainerProps {
325
335
  /** Grouped axis configuration (Y/X visibility, bounds, sizing). */
326
336
  axis?: AxisConfig;
327
337
  /**
328
- * Viewport padding. `top`/`bottom` are in pixels. `left`/`right` accept either pixels (`50`)
329
- * or data intervals (`{ intervals: 3 }`). Set to 0 for edge-to-edge sparklines. Applied on mount only.
330
- * Defaults: `{ top: 20, bottom: 20, right: { intervals: 3 }, left: { intervals: 0 } }`.
338
+ * Viewport padding around the plot area. Applied on mount only — changing
339
+ * this prop after mount is ignored. Set every side to `0` for an
340
+ * edge-to-edge sparkline.
341
+ *
342
+ * @default `{ top: 20, bottom: 20, right: { intervals: 3 }, left: { intervals: 0 } }`
331
343
  */
332
344
  padding?: {
345
+ /** Pixels of empty space above the plot area. Default `20`. */
333
346
  top?: number;
347
+ /** Pixels of empty space below the plot area. Default `20`. */
334
348
  bottom?: number;
349
+ /**
350
+ * Empty space on the right edge. A `number` is pixels (e.g. `50`); an
351
+ * object pads by data intervals on the time axis (e.g. `{ intervals: 3 }`
352
+ * leaves room for three more bars/candles past the latest point). Default
353
+ * `{ intervals: 3 }`.
354
+ */
335
355
  right?: number | {
336
356
  intervals: number;
337
357
  };
358
+ /**
359
+ * Empty space on the left edge. A `number` is pixels; an object pads by
360
+ * data intervals on the time axis. Default `{ intervals: 0 }`.
361
+ */
338
362
  left?: number | {
339
363
  intervals: number;
340
364
  };
@@ -345,6 +369,7 @@ declare interface ChartContainerProps {
345
369
  interactive?: boolean;
346
370
  /** Background grid configuration. Default: `{ visible: true }`. */
347
371
  grid?: {
372
+ /** Whether the background grid is rendered. Default: `true`. */
348
373
  visible: boolean;
349
374
  };
350
375
  /**
@@ -366,7 +391,9 @@ declare interface ChartContainerProps {
366
391
  * Only read at mount; changing this prop after the chart is created is ignored.
367
392
  */
368
393
  perf?: PerfOption;
394
+ /** Inline style for the chart's outer wrapper element. */
369
395
  style?: CSSProperties;
396
+ /** Extra class for the chart's outer wrapper element. */
370
397
  className?: string;
371
398
  }
372
399
 
@@ -449,6 +476,12 @@ export declare class ChartInstance extends EventEmitter<ChartEvents> {
449
476
  /** Auto-fit the viewport to show all data across every series. */
450
477
  fitContent(): void;
451
478
  getVisibleRange(): VisibleRange;
479
+ /**
480
+ * Return the full span of registered data, or `null` before any data has
481
+ * arrived. `{ from: dataStart, to: dataEnd }` mirrors the viewport's own
482
+ * tracking and is cheaper than recomputing from series stores.
483
+ */
484
+ getDataRange(): VisibleRange | null;
452
485
  /**
453
486
  * Imperatively set the visible time range.
454
487
  *
@@ -707,10 +740,13 @@ export declare interface ChartTheme {
707
740
  background: string;
708
741
  /** Chart area gradient [top, bottom] — subtle vignette for depth */
709
742
  chartGradient: [string, string];
743
+ /** Font family and base size used across the chart's text. */
710
744
  typography: Typography;
711
745
  /** Grid line appearance in the chart area. */
712
746
  grid: {
747
+ /** Grid line stroke colour. */
713
748
  color: string;
749
+ /** Grid line dash pattern. */
714
750
  style: 'solid' | 'dashed' | 'dotted';
715
751
  };
716
752
  /**
@@ -722,33 +758,48 @@ export declare interface ChartTheme {
722
758
  * want the subtle lightened/darkened look pass `autoGradient(color)`.
723
759
  */
724
760
  candlestick: {
761
+ /** Bullish candle (close ≥ open). */
725
762
  up: {
763
+ /** Body fill — single colour for flat, `[top, bottom]` tuple for a 2-stop vertical gradient. */
726
764
  body: string | [string, string];
765
+ /** Wick stroke colour. */
727
766
  wick: string;
728
767
  };
768
+ /** Bearish candle (close < open). */
729
769
  down: {
770
+ /** Body fill — single colour for flat, `[top, bottom]` tuple for a 2-stop vertical gradient. */
730
771
  body: string | [string, string];
772
+ /** Wick stroke colour. */
731
773
  wick: string;
732
774
  };
733
775
  };
734
776
  /** Default line series appearance including area gradient fill. */
735
777
  line: {
778
+ /** Stroke colour of the line. */
736
779
  color: string;
780
+ /** Stroke width in CSS pixels. */
737
781
  width: number;
782
+ /** Top stop of the area-fill vertical gradient (closest to the line). */
738
783
  areaTopColor: string;
784
+ /** Bottom stop of the area-fill vertical gradient (closest to the X axis). */
739
785
  areaBottomColor: string;
740
786
  };
741
787
  /** Color palette for multi-series charts (stacked bars, overlays). */
742
788
  seriesColors: string[];
743
789
  /** Bollinger band / envelope fill colors. */
744
790
  bands: {
791
+ /** Fill for the upper band region (above the middle band). */
745
792
  upper: string;
793
+ /** Fill for the lower band region (below the middle band). */
746
794
  lower: string;
747
795
  };
748
796
  /** Crosshair line and axis label styling. */
749
797
  crosshair: {
798
+ /** Stroke colour of the crosshair lines. */
750
799
  color: string;
800
+ /** Background fill of the X/Y axis label pills shown at the crosshair position. */
751
801
  labelBackground: string;
802
+ /** Text colour inside the crosshair axis label pills. */
752
803
  labelTextColor: string;
753
804
  };
754
805
  /**
@@ -758,32 +809,114 @@ export declare interface ChartTheme {
758
809
  * diverge.
759
810
  */
760
811
  axis: {
812
+ /** Default tick-label font size shared by both axes. */
761
813
  fontSize: number;
814
+ /** Default tick-label colour shared by both axes. */
762
815
  textColor: string;
816
+ /** Override the shared defaults on the X axis only. */
763
817
  x?: {
818
+ /** X-axis tick-label font size. Falls back to `axis.fontSize`. */
764
819
  fontSize?: number;
820
+ /** X-axis tick-label colour. Falls back to `axis.textColor`. */
765
821
  textColor?: string;
766
822
  };
823
+ /** Override the shared defaults on the Y axis only. */
767
824
  y?: {
825
+ /** Y-axis tick-label font size. Falls back to `axis.fontSize`. */
768
826
  fontSize?: number;
827
+ /** Y-axis tick-label colour. Falls back to `axis.textColor`. */
769
828
  textColor?: string;
770
829
  };
771
830
  };
772
831
  /** Floating label shown at the current value level on the Y axis. */
773
832
  yLabel: {
833
+ /** Font size of the value text inside the floating Y label. */
774
834
  fontSize: number;
835
+ /** Pill background when the latest delta is positive. */
775
836
  upBackground: string;
837
+ /** Pill background when the latest delta is negative. */
776
838
  downBackground: string;
839
+ /** Pill background when the latest delta is zero / unknown. */
777
840
  neutralBackground: string;
841
+ /** Text colour inside the floating Y label pill. */
778
842
  textColor: string;
779
843
  };
780
844
  /** Hover tooltip styling. */
781
845
  tooltip: {
846
+ /** Tooltip body font size. */
782
847
  fontSize: number;
848
+ /** Tooltip background fill. */
783
849
  background: string;
850
+ /** Tooltip text colour. */
784
851
  textColor: string;
852
+ /** Tooltip outer border colour. */
785
853
  borderColor: string;
786
854
  };
855
+ /**
856
+ * Navigator strip shown below the main chart — a miniature overview with a
857
+ * draggable window indicating the visible range.
858
+ *
859
+ * The `candlestick` shape mirrors the root {@link ChartTheme.candlestick}
860
+ * (including `[top, bottom]` gradient tuples) so candle-type mini views can
861
+ * share colors with the main plot.
862
+ */
863
+ navigator: {
864
+ /** Default height of the navigator strip in CSS pixels. */
865
+ height: number;
866
+ /** Strip background (behind the miniature series). */
867
+ background: string;
868
+ /** Color used for the strip's top + bottom inner-shadow separators. */
869
+ borderColor: string;
870
+ /** Line / close-price miniature color and geometry. */
871
+ line: {
872
+ /** Stroke colour of the miniature line. */
873
+ color: string;
874
+ /** Stroke width of the miniature line in CSS pixels. */
875
+ width: number;
876
+ /** Top stop of the miniature area-fill gradient. */
877
+ areaTopColor: string;
878
+ /** Bottom stop of the miniature area-fill gradient. */
879
+ areaBottomColor: string;
880
+ };
881
+ /** Colors for candlestick-type miniature rendering. */
882
+ candlestick: {
883
+ /** Bullish miniature candle (close ≥ open). */
884
+ up: {
885
+ /** Body fill — single colour for flat, `[top, bottom]` tuple for a vertical gradient. */
886
+ body: string | [string, string];
887
+ /** Wick stroke colour. */
888
+ wick: string;
889
+ };
890
+ /** Bearish miniature candle (close < open). */
891
+ down: {
892
+ /** Body fill — single colour for flat, `[top, bottom]` tuple for a vertical gradient. */
893
+ body: string | [string, string];
894
+ /** Wick stroke colour. */
895
+ wick: string;
896
+ };
897
+ };
898
+ /** The draggable visible-range window indicator. */
899
+ window: {
900
+ /** Fill inside the visible-range window. Usually a translucent tint. */
901
+ fill: string;
902
+ /** Stroke colour around the window. */
903
+ border: string;
904
+ /** Stroke width of the window border in CSS pixels. */
905
+ borderWidth: number;
906
+ };
907
+ /** Left/right resize handles on the window edges. */
908
+ handle: {
909
+ /** Stroke colour of the handle marker. */
910
+ color: string;
911
+ /** Handle marker width in CSS pixels. */
912
+ width: number;
913
+ };
914
+ /** Dim overlay covering the regions outside the window. */
915
+ mask: {
916
+ /** Fill of the dim overlay applied to regions outside the window. */
917
+ fill: string;
918
+ };
919
+ };
787
920
  }
788
921
 
789
922
  export declare function computeTooltipPosition(args: TooltipPositionArgs): TooltipPosition;
@@ -1034,6 +1167,7 @@ export declare interface LineSeriesOptions {
1034
1167
  strokeWidth: number;
1035
1168
  /** Area-fill configuration. Default: `{ visible: true }`. */
1036
1169
  area: {
1170
+ /** Whether the area gradient under the line is rendered. Default: `true`. */
1037
1171
  visible: boolean;
1038
1172
  };
1039
1173
  /**
@@ -1088,6 +1222,7 @@ export declare interface LineSeriesOptions {
1088
1222
  declare interface LineSeriesProps {
1089
1223
  /** Array of datasets — one per layer. A single line uses `[data]`. */
1090
1224
  data: TimePoint[][];
1225
+ /** Visual options override — colours per layer, stroke width, area fill, stacking, entrance animation, smoothing. */
1091
1226
  options?: Partial<LineSeriesOptions>;
1092
1227
  /** Stable series ID — same value across remounts. */
1093
1228
  id?: string;
@@ -1103,6 +1238,111 @@ export declare const mintBreeze: ThemePreset;
1103
1238
 
1104
1239
  export declare const monokaiPro: ThemePreset;
1105
1240
 
1241
+ /**
1242
+ * Miniature navigator strip with a draggable window indicator for the main
1243
+ * chart's visible range. Must be rendered as a child of `<ChartContainer>`
1244
+ * so the chart instance is available via context.
1245
+ *
1246
+ * `ChartContainer` sifts this element out of its children and places it as a
1247
+ * flex sibling below the canvas area — it does not render inline.
1248
+ */
1249
+ declare function Navigator_2({ data, height, style, className }: NavigatorProps): JSX_2.Element;
1250
+ export { Navigator_2 as Navigator }
1251
+
1252
+ /** Minimal point shape for candlestick miniature series. */
1253
+ export declare interface NavigatorCandlePoint {
1254
+ time: number;
1255
+ open: number;
1256
+ high: number;
1257
+ low: number;
1258
+ close: number;
1259
+ }
1260
+
1261
+ /**
1262
+ * Drives the navigator strip rendered below the main chart.
1263
+ *
1264
+ * Layout: the container holds a canvas (series miniature) and a DOM overlay
1265
+ * with five absolutely-positioned divs — left mask, right mask, window body,
1266
+ * left handle, right handle. The overlay is purely visual; pointer input is
1267
+ * captured on the canvas and hit-tested against the current window geometry.
1268
+ *
1269
+ * Both layers reserve `chart.yAxisWidth` on the right so the navigator's
1270
+ * active zone aligns with the main chart's plot area (matches the TimeAxis).
1271
+ *
1272
+ * Event topology — navigator is a pure listener on the chart side, never emits:
1273
+ * chart.viewportChange → reposition window DOM + redraw on next frame
1274
+ * chart.overlayChange → full redraw (catches data + theme swaps)
1275
+ * ResizeObserver → resize canvas + full redraw
1276
+ */
1277
+ export declare class NavigatorController {
1278
+ #private;
1279
+ constructor(params: NavigatorControllerParams);
1280
+ setData(data: NavigatorData): void;
1281
+ setOptions(options: NavigatorOptions): void;
1282
+ destroy(): void;
1283
+ /** CSS pixel height of the strip — theme default unless overridden. */
1284
+ get height(): number;
1285
+ }
1286
+
1287
+ export declare interface NavigatorControllerParams {
1288
+ container: HTMLElement;
1289
+ chart: ChartInstance;
1290
+ data: NavigatorData;
1291
+ options?: NavigatorOptions;
1292
+ }
1293
+
1294
+ /**
1295
+ * Data passed to the navigator. The discriminant `type` selects the miniature
1296
+ * rendering style. Line and bar accept either a single `points` array
1297
+ * (shorthand) or `series` for multi-series overlays — every series shares the
1298
+ * same y-range and is drawn in the navigator's neutral foreground color.
1299
+ * Candlestick stays single-series; multi-candlestick miniatures don't read.
1300
+ */
1301
+ export declare type NavigatorData = {
1302
+ type: 'line' | 'bar';
1303
+ points: readonly NavigatorLinePoint[];
1304
+ } | {
1305
+ type: 'line' | 'bar';
1306
+ series: readonly (readonly NavigatorLinePoint[])[];
1307
+ } | {
1308
+ type: 'candlestick';
1309
+ points: readonly NavigatorCandlePoint[];
1310
+ };
1311
+
1312
+ /** Minimal point shape for line and bar miniature series. */
1313
+ export declare interface NavigatorLinePoint {
1314
+ time: number;
1315
+ value: number;
1316
+ }
1317
+
1318
+ export declare interface NavigatorOptions {
1319
+ /**
1320
+ * Strip height in CSS pixels. When omitted, falls back to
1321
+ * `chart.getTheme().navigator.height`.
1322
+ */
1323
+ height?: number;
1324
+ }
1325
+
1326
+ export declare interface NavigatorProps {
1327
+ /**
1328
+ * Data to render in the miniature view. Shape:
1329
+ * { type: 'line' | 'bar', points: { time, value }[] }
1330
+ * { type: 'candlestick', points: { time, open, high, low, close }[] }
1331
+ *
1332
+ * Usually the same series you feed into the main chart.
1333
+ */
1334
+ data: NavigatorData;
1335
+ /** Strip height in CSS pixels. Defaults to `theme.navigator.height` (60). */
1336
+ height?: number;
1337
+ /** Style override for the outer wrapper div. */
1338
+ style?: CSSProperties;
1339
+ /** Extra class on the outer wrapper div. */
1340
+ className?: string;
1341
+ }
1342
+
1343
+ /** Series type the navigator should render in its miniature view. */
1344
+ export declare type NavigatorSeriesType = 'line' | 'bar' | 'candlestick';
1345
+
1106
1346
  export declare const nightOwl: ThemePreset;
1107
1347
 
1108
1348
  /** Convert a {@link TimeValue} (number ms or Date) to a millisecond timestamp. */
@@ -1111,6 +1351,7 @@ export declare function normalizeTime(t: TimeValue): number;
1111
1351
  export declare function NumberFlow({ value, format, locale, spinDuration, className, style }: NumberFlowProps): JSX_2.Element;
1112
1352
 
1113
1353
  declare interface NumberFlowProps {
1354
+ /** Numeric value to display. Each digit that changes between renders animates with a vertical spin. */
1114
1355
  value: number;
1115
1356
  /**
1116
1357
  * Value-to-string formatter. Defaults to the current locale's
@@ -1122,9 +1363,13 @@ declare interface NumberFlowProps {
1122
1363
  * from before this prop was a function.
1123
1364
  */
1124
1365
  format?: ((value: number) => string) | Intl.NumberFormatOptions;
1366
+ /** BCP 47 locale tag used by the default formatter. Defaults to `'en-US'`. */
1125
1367
  locale?: string;
1368
+ /** Per-digit spin animation duration in milliseconds. Defaults to `350`. */
1126
1369
  spinDuration?: number;
1370
+ /** Extra class on the root `<span>`. */
1127
1371
  className?: string;
1372
+ /** Inline style on the root `<span>`. Useful for `fontVariantNumeric: 'tabular-nums'`. */
1128
1373
  style?: CSSProperties;
1129
1374
  }
1130
1375
 
@@ -1406,7 +1651,9 @@ export declare interface PieSeriesOptions {
1406
1651
  }
1407
1652
 
1408
1653
  declare interface PieSeriesProps {
1654
+ /** Slices to render. A flat array of `{ label, value, color? }` entries. */
1409
1655
  data: PieSliceData[];
1656
+ /** Visual options override — palette, donut hole, slice gap, label rendering, hover/entrance animations. */
1410
1657
  options?: Partial<PieSeriesOptions>;
1411
1658
  /** Stable series ID — same value across remounts. */
1412
1659
  id?: string;
@@ -1531,7 +1778,9 @@ export declare const solarizedLight: ThemePreset;
1531
1778
  export declare function Sparkline({ data, theme, variant, valuePosition, formatValue, label, sublabel, color, negativeColor, area, areaFill, width, height, strokeWidth, gradient, style, }: SparklineProps): JSX_2.Element;
1532
1779
 
1533
1780
  export declare interface SparklineProps {
1781
+ /** Data points plotted by the sparkline. A flat `TimePoint[]` — the sparkline only ever shows one tiny line/bar. */
1534
1782
  data: TimePoint[];
1783
+ /** Visual theme. Drives series colour, background gradient, and the change-direction colours used in the value block. */
1535
1784
  theme: ChartTheme;
1536
1785
  /** 'line' (default) or 'bar' */
1537
1786
  variant?: SparklineVariant;
@@ -1549,6 +1798,7 @@ export declare interface SparklineProps {
1549
1798
  negativeColor?: string;
1550
1799
  /** Show area fill under line */
1551
1800
  area?: {
1801
+ /** Whether the area fill is rendered under the sparkline. Defaults to `true`. */
1552
1802
  visible: boolean;
1553
1803
  };
1554
1804
  /** @deprecated Use {@link area} instead. */
@@ -1594,6 +1844,19 @@ export declare interface ThemeConfig {
1594
1844
  axis?: Partial<ChartTheme['axis']>;
1595
1845
  yLabel?: Partial<ChartTheme['yLabel']>;
1596
1846
  tooltip?: Partial<ChartTheme['tooltip']>;
1847
+ navigator?: {
1848
+ height?: number;
1849
+ background?: string;
1850
+ borderColor?: string;
1851
+ line?: Partial<ChartTheme['navigator']['line']>;
1852
+ candlestick?: {
1853
+ up?: Partial<ChartTheme['navigator']['candlestick']['up']>;
1854
+ down?: Partial<ChartTheme['navigator']['candlestick']['down']>;
1855
+ };
1856
+ window?: Partial<ChartTheme['navigator']['window']>;
1857
+ handle?: Partial<ChartTheme['navigator']['handle']>;
1858
+ mask?: Partial<ChartTheme['navigator']['mask']>;
1859
+ };
1597
1860
  /** URL to load the font (e.g. Google Fonts). */
1598
1861
  fontUrl?: string | null;
1599
1862
  }
@@ -1808,6 +2071,7 @@ export declare type TooltipSort = 'none' | 'asc' | 'desc';
1808
2071
 
1809
2072
  /** Font family and base font size used across the chart. */
1810
2073
  export declare interface Typography {
2074
+ /** CSS `font-family` stack applied to all text rendered by the chart. */
1811
2075
  fontFamily: string;
1812
2076
  /** Base body font size — titles, infobar, pie tooltip/legend default to this. */
1813
2077
  fontSize: number;