ECharts.js 920 Bytes
Newer Older
李纪文's avatar
李纪文 committed
1
import React, { useMemo } from 'react';
崔佳豪's avatar
崔佳豪 committed
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
import { ConfigProvider } from 'antd';
import classNames from 'classnames';
import ReactEcharts from 'echarts-for-react';
import { omit } from 'lodash';
import buildOption from './utils';

const ECharts = React.forwardRef((props, ref) => {
  const { getPrefixCls } = React.useContext(ConfigProvider.ConfigContext);
  const prefixCls = getPrefixCls('basic-chart');

  const chartProps = omit(props, ['className', 'option']);
  const option = useMemo(() => {
    return buildOption(props.option);
  }, [props.option]);

  // const chartProps = pick(props, ['option', 'notMerge', 'lazyUpdate', 'style', 'className', 'theme', 'onChartReady', 'loadingOption', 'showLoading', 'onEvents', 'opts']);

  return (
    <ReactEcharts
      ref={ref}
      className={classNames(prefixCls, props.className)}
      option={option}
      {...chartProps}
    />
  );
});

export default ECharts;