forked from supervons/react-native-echarts-pro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·39 lines (37 loc) · 1.07 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* RNEcharts entrance.
* Build a bridge between echarts and React-Native.
*/
import React, { forwardRef, useImperativeHandle, useRef } from "react";
import { Container, Echarts } from "./src/components";
function APP(props, ref) {
const chartRef = useRef();
useImperativeHandle(ref, () => ({
setNewOption(option, optionSetting) {
chartRef.current.setNewOption(option, optionSetting);
},
/**
* 触发ECharts 中支持的图表行为
* Chart actions supported by ECharts are triggered through dispatchAction.
* @param {object|array} action
*/
dispatchAction(action) {
chartRef.current.dispatchAction(action);
},
/**
* Get echarts instance support function.
* @param {string} functionName
* @param {object} params
*/
async getInstance(functionName, params) {
return await chartRef.current.getInstance(functionName, params);
},
}));
return (
<Container width={props.width}>
<Echarts {...props} ref={chartRef} />
</Container>
);
}
APP = forwardRef(APP);
export default APP;