#Smart_Charts备忘录及各种难点汇总

在React中引入echarts和需要用到的图表类型和图表组件:

// 引入 ECharts 主模块
import echarts from 'echarts/lib/echarts';
// 引入需要用到的图表形状
import 'echarts/lib/chart/bar';
import 'echarts/lib/chart/pie';
// 引入提示框和标题组件...
import 'echarts/lib/component/tooltip';
import 'echarts/lib/component/title';
import 'echarts/lib/component/legend';

出现报错"dispatch is not a function"?<没有连接model>

解决办法:

@connect(({project,loading}) => ({
    project,
    loading: loading.effects['project/GetTableData'],        //特定为某一个组件添加loading
}))
@Form.create()

*在画 Charts 的函数中定义this:

var self = this;        //***重要定义!

目标图表的点击事件:<如柱状图>

TargetChart.on('click', function (recod) {}
关闭目标图表的点击事件:<通常定义在目标图表的点击事件之前!>
TargetChart.off('click');

给目标图表添加 Loading 状态:

1.先定义需要用到的 State 

Success:false,     // Chart 数据是否获取成功?<用于判断 Loading 的状态>
const {Success} = self.state;
//region<加载中...>
if (self.state.PRLoading){
    TargetChart.showLoading('default',{text:'页面正在拼命加载中...',maskColor:'#a9f0ff',textColor: '#000',});
} else if (self.state.PRLoading ==false){
    TargetChart.hideLoading();
}
if (Success) {
    self.state.PRLoading = false;
}
//endregion


猜你喜欢

转载自blog.csdn.net/iversons/article/details/80798669