hustcc / echarts-for-react

⛳️ Apache ECharts components for React wrapper. 一个简单的 Apache echarts 的 React 封装。
https://git.hust.cc/echarts-for-react
MIT License
4.56k stars 633 forks source link

How do i import stuff from eCharts when using this in isomorphic app? #212

Closed damiangreen closed 5 years ago

damiangreen commented 6 years ago

I'm using RSK and I think this line is causing me issues on page reload

const dattoHorizontalGradient = new echarts.graphic.LinearGradient(...)

I manged to get around window.document errors when using the main component by doing tihs: const EchartsReact = typeof document !== 'undefined' && require('echarts-for-react').default; // eslint-disable-line ...

  {EchartsReact &&
            this.props.option && (
              <EchartsReact
                option={option}
                style={{
                  height: '100%',
                  width: '100%',
                }}
              />
            )}

Is there another way of importing gradients I'm unaware of?

hustcc commented 6 years ago

Why you need to:

const EchartsReact = typeof document !== 'undefined' && require('echarts-for-react').default;

Use it when ssr?

damiangreen commented 6 years ago

Do i load LinearGradient from EchartsReact also? Can i only instantiate one of these objects in ComponentDidMount ?