$ npm install native-echarts --save
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.
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
import Echarts from 'native-echarts';
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} />
);
}
}
AppRegistry.registerComponent('app', () => app);
import React, { Component } from 'react';
import { View } from 'react-native';
import Echarts from 'react-native-echarts-map';
type Props = {};
export default class App extends Component<Props> {
render() {
const option = {
tooltip: {
trigger: 'item',
formatter: '{b}'
},
series: [{
name: '中国',
type: 'map',
map: 'china',
selectedMode: 'single',//multiple多选
itemStyle: {
normal: {
label: {
show: true,
textStyle: {
color: "#231816"
}
},
areaStyle: { color: '#B1D0EC' },
color: '#B1D0EC',
borderColor: '#dadfde'//区块的边框颜色
},
emphasis: {//鼠标hover样式
label: {
show: true,
textStyle: {
color: '#fa4f04'
}
}
}
},
data: [
{ name: '四川', selected: true }
]
}]
};
return (
<View style={{ marginTop: 100 }}>
<Echarts option={option} height={500} />
</View>
);
}
}
run demo
cd example
npm install
npm start
Open the xcode project in the ios directory and click run
screenshots:
Open the Android project in the android directory with Android Studio and click run.
screenshots:
native-echarts is released under the MIT license.