如果没有传series数据给Echarts,如何让Echarts显示一些提示信息,比如‘无数据’之类,我没有找到类似的配置项。
如果没有传series数据给Echarts,如何让Echarts显示一些提示信息,比如‘无数据’之类,我没有找到类似的配置项。
I solved this problem by this way: clear echarts instance first, then setOption with custom title option (without series data and hide axis line). By the way, you can add background to the option.
var showChartInfo = function (divId, infoStr) {
var msgOption = {
title: {
show: true,
textStyle:{
color:'grey',
fontSize:20
},
text: infoStr,
left: 'center',
top: 'center'
},
xAxis: {
show: false
},
yAxis: {
show: false
},
series: []
};
initChart(divId).clear() //initChart(divId): get echarts instance, you can get it by using other method
initChart(divId).hideLoading()
initChart(divId).setOption(msgOption)
};
10 回答11.1k 阅读
6 回答3k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.7k 阅读✓ 已解决
3 回答2.3k 阅读✓ 已解决
3 回答2.1k 阅读✓ 已解决
个人觉得这个逻辑并不一定放到Echarts里面去做吧?
如果是ajax获取数据传入的方式,完全可以选择在判断时候就不进行echarts渲染,改为显示提示。