react 使用 echarts

阅读 56

2022-04-08

一、安装

npm install --save echarts-for-react
npm install --save echarts

`二、引用

import * as charts from 'echarts';
import ReactEcharts from 'echarts-for-react';
type EChartsOption = charts.EChartsOption;

三、使用

export default function Echart_1() {
  const getOption = () => {
    const option: EChartsOption = {
      //........
      //(echarts的 option中的代码)
      //........
    };
    return option;
  };

  return(
	<ReactEcharts
          style={{ height: '280px', width: '360px' }}
          option={getOption()}
     />
  )
}     

精彩评论(0)

0 0 举报