Skip to content

superandrew213/react-native-charting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-charting

Originally forked from native-echarts.

react-native-charting uses Echarts.

Works for both iOS & Android using WebView.

Install

$ yarn add react-native-charting

react-native-webview is a peer dependency. If you are not already using it in your project, then please go here to install it too react-native-webview

Android

Copy ./node_modules/react-native-charting/src/components/Echarts/echart.html to ./android/app/src/main/assets/. Don't remove ./node_modules/react-native-charting/src/components/Echarts/echart.html.

iOS

Nothing else to do.

Usage

The Usage is complete consistent with Echarts.

component props:

  • option (object): The option for echarts: Documentation
  • width (number): The width of the chart. The default value is the outer container width.
  • height (number): The height of the chart. The default value is 400.
  • onPress (function): Returns event object.
  • onDataZoom (function): Returns event object.
import React, { Component } from 'react'
import { AppRegistry, StyleSheet, Text, View } from 'react-native'
import Echarts from 'react-native-charting'

export default class app extends Component {
  render() {
    const option = {
      title: {
        text: 'ECharts demo',
      },
      tooltip: {},
      legend: {
        data: ['销量'],
      },
      xAxis: {
        data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子'],
      },
      yAxis: {},
      series: [
        {
          name: '销量',
          type: 'bar',
          data: [5, 20, 36, 10, 10, 20],
        },
      ],
    }
    return (
      <Echarts
        option={option}
        height={300}
        onPress={(params) => console.log(params)}
      />
    )
  }
}

AppRegistry.registerComponent('app', () => app)

IOS

image

Android

image

License

react-native-charting is released under the MIT license.

About

Charts for react-native using Echarts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published