import React from 'react'
import Echarts from 'echarts-for-react'
import { connect } from 'dva'
import { hashcode } from '../../../utils/baseUtils'

const EchartsView = ({ chartDesigner, dispatch, optionConfig }) => {
    const { chartOption } = chartDesigner;
    const option = { ...chartOption, ...optionConfig };
    return <Echarts
        key={hashcode(option)}
        option={option}
        className='rc-echarts'
        style={{height: '100%'}}
    />
}

function mapStateToProps({ present: { chartDesigner } }) {
    return { chartDesigner: chartDesigner }
}

export default connect(mapStateToProps)(EchartsView);