index.js 597 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
import React, { useMemo } from 'react';
import ReactEcharts from 'echarts-for-react';

export default function EchartsDiy(props){
  const { json, uuid, option, value } = props;
  const opt = useMemo(() => {
    return (value && typeof value === 'object' && Object.keys(value).length) ? value : option;
  }, [value, option]);
  // console.log(opt);
  if(!opt){
    return null;
  }
  return (
    <ReactEcharts
      style={{ height: json.height || 500 }}
      key={uuid}
      option={opt}
      notMerge={true}
      lazyUpdate={true}
      theme={'theme_name'}
      onEvents={{}}
    />
  )
}