@duxapp/react-native-echarts is a React Native wrapper for Apache ECharts built on top of @duxapp/react-native-canvas.
If your project has not installed @shopify/react-native-skia yet, install it first:
yarn add @shopify/react-native-skiaor
npm install @shopify/react-native-skiaThen install @duxapp/react-native-echarts:
yarn add @duxapp/react-native-echartsor
npm install @duxapp/react-native-echartsRequired peer dependencies:
reactreact-native@shopify/react-native-skia
import { ScrollView, StyleSheet } from 'react-native';
import { Chart } from '@duxapp/react-native-echarts';
const lineOption = {
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
},
yAxis: {
type: 'value',
},
series: [
{
data: [150, 230, 224, 218, 135, 147, 260],
type: 'line',
smooth: true,
},
],
};
export default function Demo() {
return (
<ScrollView contentContainerStyle={styles.content}>
<Chart
style={styles.chart}
option={lineOption}
/>
</ScrollView>
);
}
const styles = StyleSheet.create({
content: {
padding: 20,
},
chart: {
width: '100%',
height: 320,
},
});optionupdates are forwarded withchart.setOption(option, setOptionOptions).- Touch input is translated into zrender events so tooltip, click, and highlight interactions can still work on React Native.
- The wrapper uses the bundled
echarts/dist/echarts.jsentry to avoid Metro/Expo compatibility issues with the modular ESM build.