Skip to content

feat: add custom React trade markers for KLine chart#17

Open
tonichiga wants to merge 9 commits intohellohublot:mainfrom
tonichiga:main
Open

feat: add custom React trade markers for KLine chart#17
tonichiga wants to merge 9 commits intohellohublot:mainfrom
tonichiga:main

Conversation

@tonichiga
Copy link
Copy Markdown
Contributor

feat: add custom React trade markers for KLine chart

Summary

This PR adds support for rendering trade markers with a custom React component in react-native-kline-view.

Instead of only drawing native marker dots, consumers can now provide tradeComponent(trade, count) and fully control the marker UI.

What changed

  • Added JS wrapper component in index.js to:
    • Accept tradeComponent prop
    • Enable native custom marker mode via useCustomTradeMarker
    • Receive marker layout events via onTradeMarkersLayout
    • Render marker overlays in React with absolute positioning and pointerEvents="none"
  • Updated TypeScript types in index.d.ts:
    • Added TTrade
    • Added tradeComponent?: (trade: TTrade, count: number) => ReactNode
    • Updated default export type to functional component signature
  • iOS native updates:
    • Added useCustomTradeMarker and onTradeMarkersLayout to config/bridge
    • Emitted visible marker positions from HTKLineView (debounced)
    • Disabled default native trade marker drawing in custom mode
    • Exported new view props in RNKLineView.m
  • Android gradle repository remains on mavenCentral().

New feature

Custom trade marker rendering

You can now render trade markers using your own React UI.

trade payload shape:

  • id: string
  • timestamp: number
  • price: number
  • type: "buy" | "sell"

count is provided as the second argument.

Screenshot

Custom trade marker overlay

Notes

  • Marker overlay rendering is non-interactive (pointerEvents="none") to preserve chart gestures.
  • iOS marker layout emission is debounced to reduce event pressure during scroll and redraw.

Testing checklist

  • iOS: custom markers appear at expected candle positions
  • iOS: chart pan/zoom/long-press still work with overlays
  • iOS: disabling tradeComponent falls back to native markers
  • TypeScript: tradeComponent prop and TTrade type are available
  • Android: no regression in build and chart rendering

…nfiguration

- Updated iOS and Android implementations to support open/close trade prices and counts.
- Added scrollEnabled property to HTKLineConfigManager for better user control.
- Introduced visual markers for open/close trades in the chart view.
- Adjusted dependencies for lottie-ios to ensure compatibility.
- Introduced fitBarsCount property in HTKLineConfigManager for limiting visible bars.
- Updated reloadOptionList method to handle fitBarsCount and adjust modelArray accordingly.
- Enhanced HTKLineContainerView to manage chart scaling based on fitBarsCount.
- Added resetChartScale method in ScrollAndScaleView to reset the chart scale.
- Modified HTKLineView to adjust content size and scrolling behavior based on fitBarsCount.
- Updated TypeScript definitions to include fitBarsCount and related properties.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant