1.3.6 • Published 4 years ago

react-native-byron-kline v1.3.6

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

react-native-byron-kline

基于TradingView的 react-native k线图表

用法

$ yarn add react-native-byron-kline --save

import { WebView } from 'react-native-webview'
import { sendMessageHtml, IOnMessage } from 'react-native-byron-kline'

class WebViewScreen extends React.Component {
  public chart: WebView | null = null
  
  public onLoadEnd() {
    if (this.chart) {
      const msg = sendMessageHtml('initChart', {
        symbol: 'btcusdt',
        interval: '5',
        pricescale: 100,
        isDebug: true,
        datafeedConfig: {}, // 具体参数请查看types/chart.min.d.ts里面DatafeedConfiguration接口,或teadingview api
        optionsConfig: {},  // 具体参数请查看types/chart.min.d.ts里面ChartingLibraryWidgetOptions接口,或teadingview api
        symbolConfig: {} // 具体参数请查看types/chart.min.d.ts里面LibrarySymbolInfo接口,或teadingview api
      })
      this.chart.injectJavaScript(msg)
    }
  }
  
  public onMessage(data: string) {
    const msg: IOnMessage = JSON.parse(data)
    switch (msg.event) {
      case 'fetchHistoryData':
        // 请求历史数据
        // 返回历史数据给图表
      break
      case 'fetchMoreData':
        // 请求更多数据
        // 当图表左滑需要更多数据时会响应该事件给rn
      break
      case 'closeLoading':
        // 图表库渲染数据完成
        // 可以在此执行关闭loading(rn视图的)等事件
      break
      case 'switchingCycle':
        // 图表库切换周期
      break
    }
  }
  
  public render() {
    return (
      <View style={{ flex: 1 }}>
        <WebView
          style={{ flex: 1 }}
          originWhitelist={['*']}
          ref={ref => (this.chart = ref)}
          source={require('react-native-byron-kline/dist/index.html')}
          onMessage={evt => this.onMessage(evt.nativeEvent.data)}
          onLoadEnd={this.onLoadEnd.bind(this)}
         />
      </View>
    )
  }
}

kline_view kline_ide_1 kline_ide_2

1.3.6

4 years ago

1.3.5

4 years ago

1.3.2-beta

4 years ago

1.3.3-beta

4 years ago

1.3.1-beta

5 years ago

1.3.0

5 years ago

1.2.9

5 years ago

1.2.8

5 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago