0.1.2 • Published 8 years ago

babycannotsay-react-native-charting v0.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

react-native-charting

Originally forked from native-echarts.

react-native-charting uses Echarts.

Works for both iOS & Android using WebView.

Install

$ npm i --save react-native-charting

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.
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.

0.1.2

8 years ago