import * as React from 'react';
import { connect } from 'dva';
import { Form } from 'antd';
import { FormComponentProps } from 'antd/lib/form/Form';
import * as echarts from 'echarts'; //1.引入 echarts
interface Props extends FormComponentProps {
dispatch: any;
}
class medicalRecordScore extends React.Component<Props, any> {
componentDidMount() {
this.echarts() //2.调用 echarts函数
}
echarts = () => { //3.函数 (记得return)
let chartDom = document.getElementById('main');
let myChart = echarts.init(chartDom);
let option = {
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [
{
data: [150, 230, 224, 218, 135, 147, 260],
type: 'line'
}
]
};;
return myChart.setOption(option)
}
render() {
return (
<div id='main' style={{ height: 250, width: 300 }}></div> //4. 装图标的元素
);
}
}
export default Form.create<Props>()(medicalRecordScore);
页面效果: