判断传入的数据是否为空,然后根据是否为空来判断图片的隐藏与显示
const emptyOption = {title: {show: true,textStyle: {color: 'grey',fontSize: 20},text: infoStr,left: 'center',top: 'center'},xAxis: {show: false},yAxis: {show: false},series: []}echartsInstance.clear()echartsInstance.hideLoading()
showLoading
showLoading显示暂无数据
- 只想显示些文字在上面,或者showLoading 时不要动画,只要文字
- 把动画效果color设为和你背景一致,这样就可以”隐藏”动画效果,只会显示暂无数据文字,
- 例如,背景颜色是白色,就将动画效果color就设为#fff
https://echarts.apache.org/zh/api.html#echartsInstance.showLoading
myChart.showLoading({text: '暂无数据',color: '#fff',textColor: '#8a8e91',maskColor: 'rgba(255, 255, 255, 0.8)',});
echarts暂无数据参考
https://github.com/apache/echarts/issues/4829
