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

const EchartsView = ({ chartDesigner, dispatch }) => {
    const option = resolveChartOption(chartDesigner.chartOption);
    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);