react-native-vroom-chart 0.15.0 → 0.17.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.
Files changed (53) hide show
  1. package/cpp/VroomChartHostObject.cpp +252 -1
  2. package/cpp/_core_include/vroom/vroom_chart.h +178 -4
  3. package/cpp/_core_src/atr.cpp +67 -0
  4. package/cpp/_core_src/atr.h +44 -0
  5. package/cpp/_core_src/atr_pane.cpp +162 -0
  6. package/cpp/_core_src/atr_pane.h +48 -0
  7. package/cpp/_core_src/candles.cpp +15 -14
  8. package/cpp/_core_src/chart.cpp +758 -200
  9. package/cpp/_core_src/chart.h +221 -3
  10. package/cpp/_core_src/chart_facade.cpp +236 -23
  11. package/cpp/_core_src/color_lerp.h +28 -0
  12. package/cpp/_core_src/fair_value_gaps.cpp +76 -0
  13. package/cpp/_core_src/fair_value_gaps.h +54 -0
  14. package/cpp/_core_src/fvg_overlay.cpp +262 -0
  15. package/cpp/_core_src/fvg_overlay.h +43 -0
  16. package/cpp/_core_src/ichimoku.cpp +65 -0
  17. package/cpp/_core_src/ichimoku.h +45 -0
  18. package/cpp/_core_src/labels.cpp +3 -0
  19. package/cpp/_core_src/line_morph.h +159 -0
  20. package/cpp/_core_src/loading_line.cpp +183 -0
  21. package/cpp/_core_src/loading_line.h +38 -0
  22. package/cpp/_core_src/loading_wave.h +140 -0
  23. package/cpp/_core_src/ma_overlay.cpp +273 -45
  24. package/cpp/_core_src/ma_overlay.h +64 -2
  25. package/cpp/_core_src/macd.cpp +24 -1
  26. package/cpp/_core_src/macd.h +16 -0
  27. package/cpp/_core_src/macd_pane.cpp +71 -62
  28. package/cpp/_core_src/macd_pane.h +13 -1
  29. package/cpp/_core_src/pane_series.h +169 -0
  30. package/cpp/_core_src/price_indicator.cpp +21 -7
  31. package/cpp/_core_src/price_indicator.h +11 -1
  32. package/cpp/_core_src/price_indicator_anim.h +81 -0
  33. package/cpp/_core_src/rsi.cpp +4 -0
  34. package/cpp/_core_src/rsi.h +7 -0
  35. package/cpp/_core_src/rsi_pane.cpp +85 -29
  36. package/cpp/_core_src/rsi_pane.h +11 -1
  37. package/cpp/_core_src/theme.cpp +5 -0
  38. package/cpp/_core_src/tip_geometry.h +55 -0
  39. package/cpp/_core_src/viewport.h +68 -0
  40. package/lib/index.d.mts +281 -3
  41. package/lib/index.d.ts +281 -3
  42. package/lib/index.js +292 -14
  43. package/lib/index.js.map +1 -1
  44. package/lib/index.mjs +292 -14
  45. package/lib/index.mjs.map +1 -1
  46. package/package.json +1 -1
  47. package/src/VroomChart.tsx +33 -3
  48. package/src/dataTransitions.ts +47 -0
  49. package/src/index.ts +5 -0
  50. package/src/jsi.d.ts +139 -1
  51. package/src/theme.ts +1 -0
  52. package/src/types.ts +5 -0
  53. package/src/useChartCore.ts +402 -8
package/lib/index.d.mts CHANGED
@@ -106,6 +106,19 @@ type VroomTheme = {
106
106
  crosshairTarget?: VroomColor;
107
107
  /** Line-chart-mode close polyline color. Defaults to violet, matching the RSI line. */
108
108
  lineColor?: VroomColor;
109
+ /**
110
+ * The line drawn across the plot while loading (see the `loading` prop).
111
+ * Defaults to inheriting `grid`: the gridlines are already the chart's tone
112
+ * for structure rather than data, which is what the line is, so matching
113
+ * them keeps it from being read as a series.
114
+ *
115
+ * The line breathes between roughly 60% and 100% of whatever color it ends
116
+ * up with — a pulse, not a dimmer, so a recessive color stays legible. Any
117
+ * alpha given here multiplies into that, so an opaque color is the usual
118
+ * choice. Pass `lineColor` to make the line read as the chart's own series
119
+ * warming up instead.
120
+ */
121
+ skeleton?: VroomColor;
109
122
  /** Line-chart-mode polyline stroke width in px. Defaults to 1.5. */
110
123
  lineWidth?: number;
111
124
  /**
@@ -194,6 +207,14 @@ type TransitionEasing = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out';
194
207
  * (e.g. a fixed lookback).
195
208
  */
196
209
  type IntervalTransition = 'transform' | 'fade';
210
+ /**
211
+ * How a live update to the series being displayed animates. `'none'` (default)
212
+ * applies it on the next frame with no animation and leaves the viewport where
213
+ * it is. `'transform'` eases the in-progress bar into its new values and, when
214
+ * the view is already pinned to the newest bar, slides the series left as each
215
+ * new bar arrives.
216
+ */
217
+ type StreamTransition = 'none' | 'transform';
197
218
  /** Active drawing tool while in `draw` mode. `null` draws nothing. */
198
219
  type DrawTool = null | 'line' | 'box' | 'pencil' | 'path';
199
220
  /** A drawing anchor in data space, so it stays glued to the candles on pan/zoom. */
@@ -436,6 +457,16 @@ type RSIConfig = {
436
457
  bandColor?: string | number;
437
458
  /** Draw the overbought/oversold rules. Default true. */
438
459
  bandsVisible?: boolean;
460
+ /**
461
+ * Shade the stretches where the RSI line sits past a band, fading out at the
462
+ * rule and deepening toward the end of the scale, so how far a reading went
463
+ * past the threshold reads at a glance. Default true.
464
+ *
465
+ * Colored from the theme's `accentBull` (overbought) and `accentBear`
466
+ * (oversold), the same pair the volume bars and MACD histogram use. Never
467
+ * reaches full opacity — the line and its rule stay legible through it.
468
+ */
469
+ extremeFill?: boolean;
439
470
  };
440
471
  /**
441
472
  * A moving-average overlay line drawn on the price pane. Provide an array of
@@ -505,6 +536,180 @@ type BollingerBandsConfig = {
505
536
  /** Fill opacity 0..1, applied to the upper band color. Default 0.1. */
506
537
  fillOpacity?: number;
507
538
  };
539
+ /**
540
+ * Ichimoku Kinko Hyo overlay config. Five lines on the price pane plus the
541
+ * cloud (kumo) shaded between the two leading spans. No pane is reserved.
542
+ *
543
+ * Unlike the other overlays, three of the lines are drawn away from the bar
544
+ * they were computed on:
545
+ *
546
+ * - Senkou A and B lead by `displacement` bars, so the cloud extends past the
547
+ * newest candle into empty time. The chart reserves that space when it frames
548
+ * itself, so the forward cloud is on screen without panning.
549
+ * - Chikou lags by `displacement` bars.
550
+ *
551
+ * Ichimoku is built on highs and lows rather than a single price series, so it
552
+ * takes no {@link MASource} or {@link MAKind}.
553
+ *
554
+ * Like the other price-pane overlays, its values don't feed the automatic
555
+ * y-axis fit — the cloud can run off the top or bottom of the pane on a chart
556
+ * scaled to the candles alone.
557
+ */
558
+ type IchimokuConfig = {
559
+ /** Draw the indicator. Default false. */
560
+ enabled?: boolean;
561
+ /** Tenkan-sen (conversion) lookback. Default 9, clamped to >= 1. */
562
+ tenkanPeriod?: number;
563
+ /** Kijun-sen (base) lookback. Default 26, clamped to >= 1. */
564
+ kijunPeriod?: number;
565
+ /** Senkou Span B lookback. Default 52, clamped to >= 1. */
566
+ senkouBPeriod?: number;
567
+ /**
568
+ * Bars the cloud leads by and Chikou lags by. Default 26, clamped to >= 0.
569
+ * Changing it only moves what's already drawn — the lines themselves don't
570
+ * recompute.
571
+ */
572
+ displacement?: number;
573
+ /** Tenkan-sen color (hex string or packed ARGB number). Default blue. */
574
+ tenkanColor?: string | number;
575
+ /** Tenkan-sen stroke width in px. Default 1. */
576
+ tenkanWidth?: number;
577
+ /** Draw the Tenkan-sen. Default true. */
578
+ tenkanVisible?: boolean;
579
+ /** Kijun-sen color. Default red. */
580
+ kijunColor?: string | number;
581
+ /** Kijun-sen stroke width in px. Default 1. */
582
+ kijunWidth?: number;
583
+ /** Draw the Kijun-sen. Default true. */
584
+ kijunVisible?: boolean;
585
+ /** Senkou Span A color. Default green. */
586
+ senkouAColor?: string | number;
587
+ /** Senkou Span A stroke width in px. Default 1. */
588
+ senkouAWidth?: number;
589
+ /** Draw the Senkou Span A edge. Default true. */
590
+ senkouAVisible?: boolean;
591
+ /** Senkou Span B color. Default orange. */
592
+ senkouBColor?: string | number;
593
+ /** Senkou Span B stroke width in px. Default 1. */
594
+ senkouBWidth?: number;
595
+ /** Draw the Senkou Span B edge. Default true. */
596
+ senkouBVisible?: boolean;
597
+ /** Chikou span color. Default teal. */
598
+ chikouColor?: string | number;
599
+ /** Chikou span stroke width in px. Default 1. */
600
+ chikouWidth?: number;
601
+ /** Draw the Chikou span. Default true. */
602
+ chikouVisible?: boolean;
603
+ /** Draw the cloud between the two leading spans. Default true. */
604
+ cloudVisible?: boolean;
605
+ /** Cloud fill where Senkou A is above Senkou B. Default green. */
606
+ bullishCloudColor?: string | number;
607
+ /** Cloud fill where Senkou A is below Senkou B. Default red. */
608
+ bearishCloudColor?: string | number;
609
+ /** Cloud opacity 0..1, applied to whichever cloud color is in play. Default 0.15. */
610
+ cloudOpacity?: number;
611
+ };
612
+ /**
613
+ * Fair Value Gap overlay config. Shaded boxes on the price pane marking
614
+ * three-candle imbalances — a run so fast the first and third candles' wicks
615
+ * never overlap, leaving a band of price that was skipped.
616
+ *
617
+ * A gap is bullish when `candles[i - 1].high < candles[i + 1].low` and bearish
618
+ * when `candles[i - 1].low > candles[i + 1].high`, and spans the untouched
619
+ * range between those two wicks. Each box is anchored to the middle bar's open
620
+ * and runs `boxLength` bars to the right, or to the pane's edge under
621
+ * `extendBoxes`.
622
+ *
623
+ * Gaps are tracked until price trades back through them — see `fillType` for
624
+ * which price settles that, and `deleteAfterFill` for what happens once it
625
+ * does. With `showInverse`, a filled gap carries on as a zone of the opposite
626
+ * polarity. Unlike the line overlays, the boxes are pure geometry: they don't
627
+ * feed the automatic y-axis fit.
628
+ */
629
+ type FairValueGapsConfig = {
630
+ /** Draw the indicator. Default false. */
631
+ enabled?: boolean;
632
+ /** How many bars back to scan for gaps. Default 300, clamped to >= 0. */
633
+ maxBarsBack?: number;
634
+ /**
635
+ * Withhold a gap until its third candle closes. Default false, so a gap
636
+ * formed by the still-forming bar appears immediately and disappears again
637
+ * if that bar fills back in.
638
+ */
639
+ waitForClose?: boolean;
640
+ /**
641
+ * Which price counts as trading back through the gap. `'close'` (default)
642
+ * needs a candle to close past the far edge; `'wick'` settles it the moment
643
+ * a high or low reaches through.
644
+ */
645
+ fillType?: 'close' | 'wick';
646
+ /**
647
+ * Hide a gap once it's been filled. Default true. When false the box stays
648
+ * but stops at the bar that filled it, leaving a record of the rebalance.
649
+ */
650
+ deleteAfterFill?: boolean;
651
+ /**
652
+ * Run every box to the right edge of the pane instead of ending it after
653
+ * `boxLength` bars. Default false. A filled box still stops at its fill bar.
654
+ */
655
+ extendBoxes?: boolean;
656
+ /** Box width in bars when `extendBoxes` is off. Default 20, clamped to >= 1. */
657
+ boxLength?: number;
658
+ /** Fill color for bullish gaps (hex string or packed ARGB). Default green. */
659
+ bullishColor?: VroomColor;
660
+ /** Fill color for bearish gaps. Default red. */
661
+ bearishColor?: VroomColor;
662
+ /** Fill opacity 0..1, applied to whichever fill color is in play. Default 0.15. */
663
+ opacity?: number;
664
+ /** Draw the box outline. Default true. */
665
+ borderVisible?: boolean;
666
+ /** Outline style. Default `'solid'`. */
667
+ borderStyle?: 'solid' | 'dotted' | 'dashed';
668
+ /** Outline stroke width in px. Default 1. */
669
+ borderWidth?: number;
670
+ /** Outline color for bullish gaps. Defaults to `bullishColor` at full alpha. */
671
+ bullishBorderColor?: VroomColor;
672
+ /** Outline color for bearish gaps. Defaults to `bearishColor` at full alpha. */
673
+ bearishBorderColor?: VroomColor;
674
+ /** Draw a text label on each box. Default true. */
675
+ showLabels?: boolean;
676
+ /** Label text. Default `'FVG'`. */
677
+ label?: string;
678
+ /**
679
+ * Bars of clearance between the box and its label, used only under
680
+ * `extendBoxes` — a fixed-length box places the label inside its right end.
681
+ * Default 10, clamped to >= 0.
682
+ */
683
+ labelDistance?: number;
684
+ /** Label color. Defaults to the box's border color. */
685
+ labelColor?: VroomColor;
686
+ /** Label font size in px. Defaults to the axis font size. */
687
+ labelFontSize?: number;
688
+ /**
689
+ * Keep drawing a gap after it's been filled, with its polarity flipped — the
690
+ * band price rejected on the way through becomes a zone of the opposite
691
+ * kind. Default false.
692
+ *
693
+ * The inverse box starts where the original one stops, at the close of the
694
+ * bar that filled the gap, and lasts until price reclaims the band the other
695
+ * way (by the same rule `fillType` sets). This pairs with the default
696
+ * `deleteAfterFill: true`: the original box vanishes at the fill and the
697
+ * inverse takes over from there.
698
+ */
699
+ showInverse?: boolean;
700
+ /**
701
+ * Fill color for inverted zones that are bullish — that is, for *bearish*
702
+ * gaps price has broken above. Defaults to `bullishColor`.
703
+ */
704
+ inverseBullishColor?: VroomColor;
705
+ /**
706
+ * Fill color for inverted zones that are bearish — that is, for *bullish*
707
+ * gaps price has broken below. Defaults to `bearishColor`.
708
+ */
709
+ inverseBearishColor?: VroomColor;
710
+ /** Label text on inverted boxes. Default `'iFVG'`. */
711
+ inverseLabel?: string;
712
+ };
508
713
  /**
509
714
  * Volume bar config. One bottom-anchored bar per candle on the price pane,
510
715
  * drawn under the candles and sharing their x position and body width.
@@ -828,6 +1033,37 @@ type MACDConfig = {
828
1033
  /** Draw the zero-reference line. Default true. */
829
1034
  zeroLineVisible?: boolean;
830
1035
  };
1036
+ /**
1037
+ * How the true-range series is smoothed into ATR. `'rma'` is Wilder's original
1038
+ * (alpha = 1/period) and the conventional default; the other two are the
1039
+ * ordinary moving averages applied to the same series.
1040
+ *
1041
+ * Distinct from {@link MAKind}, which the other indicators use — RMA is
1042
+ * specific to Wilder's indicators and isn't offered elsewhere.
1043
+ */
1044
+ type ATRSmoothing = 'rma' | 'sma' | 'ema';
1045
+ /**
1046
+ * ATR (Average True Range) indicator config. Rendered in its own pane below the
1047
+ * candles: a single line measuring volatility in price units.
1048
+ *
1049
+ * True Range is the widest of the bar's own high-low span and the two gaps from
1050
+ * its extremes to the previous close, so an overnight jump the bar's range
1051
+ * misses still counts. ATR smooths that series over `period` bars. It is
1052
+ * strictly positive and unbounded, so the pane fits 0..peak from its bottom
1053
+ * edge rather than centering on a reference level.
1054
+ */
1055
+ type ATRConfig = {
1056
+ /** Draw the pane. Default false. */
1057
+ enabled?: boolean;
1058
+ /** Lookback in candles. Default 14. */
1059
+ period?: number;
1060
+ /** Smoothing applied to the true-range series. Default `'rma'`. */
1061
+ smoothing?: ATRSmoothing;
1062
+ /** Line color (hex string or packed ARGB number). Default teal. */
1063
+ lineColor?: string | number;
1064
+ /** Line stroke width in px. Default 1.5. */
1065
+ lineWidth?: number;
1066
+ };
831
1067
  /**
832
1068
  * Platform-agnostic props shared by every vroom chart component. Each platform
833
1069
  * extends this with its own `style` typing (and any platform-only props) to
@@ -836,6 +1072,23 @@ type MACDConfig = {
836
1072
  type VroomChartCoreProps = {
837
1073
  /** OHLCV bars to render. The only required prop. */
838
1074
  candles: Candle[];
1075
+ /**
1076
+ * Whether the series is still being fetched. While this is true *and*
1077
+ * `candles` is empty, the chart draws a single grey line across the plot,
1078
+ * drifting in a slow sine wave, in place of the scene. Gestures, the
1079
+ * crosshair, the price badge, the axis labels and any indicator panes are all
1080
+ * suppressed for the duration.
1081
+ *
1082
+ * When the data arrives the line doesn't cut away — it becomes the chart, in
1083
+ * two steps that split `transitionMs`: it reshapes to pass through the
1084
+ * vertical centre of every candle about to be drawn, then fades out while
1085
+ * those candles grow outward from it and their color fades up.
1086
+ *
1087
+ * Passing `candles` alongside `loading` leaves the real chart up, so a
1088
+ * background refresh of an already-loaded series won't blank out. Default
1089
+ * false.
1090
+ */
1091
+ loading?: boolean;
839
1092
  /**
840
1093
  * Identity of the data series (e.g. "BTC-USD"). When it changes between
841
1094
  * renders the chart resets to the default view (most recent candles + price
@@ -887,17 +1140,41 @@ type VroomChartCoreProps = {
887
1140
  * motion still snaps.
888
1141
  */
889
1142
  intervalTransition?: IntervalTransition;
1143
+ /**
1144
+ * How a live update to the series already on screen animates — a tick to the
1145
+ * in-progress bar, or a newly closed bar arriving. `'none'` (default) snaps,
1146
+ * matching a chart with no streaming at all.
1147
+ *
1148
+ * `'transform'` eases the last bar (and every indicator reading from it) from
1149
+ * its old shape into its new one. When a new bar arrives *and* the view is
1150
+ * still pinned to the newest bar, the window advances with it so the series
1151
+ * translates left. A view panned back into history is never moved.
1152
+ */
1153
+ streamTransition?: StreamTransition;
1154
+ /**
1155
+ * Duration (ms) of the `streamTransition` animation. Default ~150 — shorter
1156
+ * than `transitionMs`, since ticks can arrive faster than a 300ms curve can
1157
+ * land. `0` snaps. Follows `transitionEasing`. Ignored (snaps) when the OS
1158
+ * requests reduced motion.
1159
+ */
1160
+ streamTransitionMs?: number;
890
1161
  theme?: VroomTheme;
891
1162
  /** RSI indicator (pane below the candles). Omit/disable to hide it. */
892
1163
  rsi?: RSIConfig;
893
1164
  /** MACD indicator (its own pane below the candles). Omit/disable to hide it. */
894
1165
  macd?: MACDConfig;
1166
+ /** ATR indicator (its own pane below the candles). Omit/disable to hide it. */
1167
+ atr?: ATRConfig;
895
1168
  /** Moving-average overlay lines (SMA/EMA) drawn on the price pane. */
896
1169
  movingAverages?: MovingAverageOverlay[];
897
1170
  /** VWAP overlay (session anchor, configurable reset). */
898
1171
  vwap?: VWAPConfig;
899
1172
  /** Bollinger Bands overlay (three lines + fill on the price pane). */
900
1173
  bollingerBands?: BollingerBandsConfig;
1174
+ /** Ichimoku Kinko Hyo overlay (five lines + the cloud on the price pane). */
1175
+ ichimoku?: IchimokuConfig;
1176
+ /** Fair Value Gap overlay (shaded imbalance boxes on the price pane). */
1177
+ fairValueGaps?: FairValueGapsConfig;
901
1178
  /** Volume bars under the candles. On by default; disable or restyle them here. */
902
1179
  volume?: VolumeConfig;
903
1180
  /** Resting-order / order-book liquidity bands drawn behind the candles. */
@@ -1087,8 +1364,9 @@ declare global {
1087
1364
  * Skia-rendered candlestick chart. Pass OHLCV `candles` and size it via `style`
1088
1365
  * (it fills its parent by default). Pan to scroll, pinch to zoom, drag the
1089
1366
  * price/time axes to rescale, and long-press for the crosshair. Optional
1090
- * indicators (`rsi`, `macd`, `movingAverages`, `vwap`), colors (`theme`), and
1091
- * events (`onCrosshair`, `onViewportChange`) are configured through props.
1367
+ * indicators (`rsi`, `macd`, `movingAverages`, `vwap`, `bollingerBands`,
1368
+ * `ichimoku`, and more), colors (`theme`), and events (`onCrosshair`,
1369
+ * `onViewportChange`) are configured through props.
1092
1370
  *
1093
1371
  * @see {@link VroomChartProps} for the full prop reference.
1094
1372
  */
@@ -1125,4 +1403,4 @@ declare function classifyTransition(prev: Candle[] | null, next: Candle[], serie
1125
1403
  */
1126
1404
  declare function timeframeWindow(oldWindow: VisibleRange, oldStepMs: number, oldLastMs: number, newStepMs: number, newLastMs: number): VisibleRange;
1127
1405
 
1128
- export { type BollingerBandsConfig, type Candle, type ChartType, type CrosshairEvent, type DataTransition, type DefaultDrawingStyle, type Footprint, type FootprintEvent, type FootprintSide, type FootprintsStyle, type IntervalTransition, type MACDConfig, type MAKind, type MASource, type MovingAverageOverlay, type PlotRect, type PriceLine, type PriceLinesStyle, type RSIConfig, type TransitionEasing, type VWAPConfig, type VisibleRange, type VolumeConfig, VroomChart, type VroomChartProps, type VroomColor, type VroomTheme, classifyTransition, inferStepMs, timeframeWindow };
1406
+ export { type ATRConfig, type ATRSmoothing, type BollingerBandsConfig, type Candle, type ChartType, type CrosshairEvent, type DataTransition, type DefaultDrawingStyle, type FairValueGapsConfig, type Footprint, type FootprintEvent, type FootprintSide, type FootprintsStyle, type IchimokuConfig, type IntervalTransition, type MACDConfig, type MAKind, type MASource, type MovingAverageOverlay, type PlotRect, type PriceLine, type PriceLinesStyle, type RSIConfig, type StreamTransition, type TransitionEasing, type VWAPConfig, type VisibleRange, type VolumeConfig, VroomChart, type VroomChartProps, type VroomColor, type VroomTheme, classifyTransition, inferStepMs, timeframeWindow };