Baidu echarts for React Native
$ npm install --save rn-bd-echarts
or
$ yarn add rn-bd-echarts
react-native link rn-bd-echarts
-
Add the following lines to
android/settings.gradle
:include ':rn-bd-echarts' project(':rn-bd-echarts').projectDir = new File(settingsDir, '../node_modules/rn-bd-echarts/android')
-
Add the compile line to the dependencies in
android/app/build.gradle
:dependencies { ... compile project(':rn-bd-echarts') }
-
Add the import and link the package in
MainApplication.java
:import com.rnbdecharts.RnBdEchartsPackage; // <-- add this import public class MainApplication extends Application implements ReactApplication { @Override protected List<ReactPackage> getPackages() { return Arrays.<ReactPackage>asList( new MainReactPackage(), new RnBdEchartsPackage() // <-- add this line ); } }
/**
The formatter does not support function in the configuration items
support `formatter: '{b}: {c}'`
not support `formatter: function(){}`
**/
import RNECharts from 'rn-bd-echarts';
class ChartTest extends Component{
render(){
return (
<RNECharts
ref={charts => this.charts = charts}
option={this.state.option}
/>
)
}
}
this.charts.dispatchAction({type: 'highlight',seriesIndex: 2});
this.charts.on('click', (e) => {console.log(e)});
this.charts.off('click');