在react 中使用echarts动态更新数据

Posted by Xiaosa's Blog on April 13, 2020
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
import ReactEcharts from 'echarts-for-react';

class EchartsProjects extends Component {
    getOption = () => ({option}})

    updateOption = () => (
        const option = this.getOption()

        // do Update
        option.series[0].data = this.pieData
        option.legend.data = this.legendData

        this.echartsElement.getEchartsInstance().setOption(option)
    )

    render() {
        return <ReactEcharts
            lazyUpdate
            ref={(e) => {this.echartsElement = e;}}
            option={this.getOption()}
            style=
            className={'react_for_echarts'}
               />
    }
  }