Echarts如何显示No Data To Display提示信息当没有传series的时候

如果没有传series数据给Echarts,如何让Echarts显示一些提示信息,比如‘无数据’之类,我没有找到类似的配置项。

阅读 10.5k
3 个回答

个人觉得这个逻辑并不一定放到Echarts里面去做吧?
如果是ajax获取数据传入的方式,完全可以选择在判断时候就不进行echarts渲染,改为显示提示。

在页面判断类似于
`<div ng-if="noData">无数据</div>
<div ng-if="!noData" id="echart">echart渲染</div>
`

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)
};
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题