echarts icon indicating copy to clipboard operation
echarts copied to clipboard

echarts3如何实现“暂无数据”

Open pbnull opened this issue 9 years ago • 7 comments

One-line summary [问题简述]

echarts3中为什么删去了noDataLoadingOption的方法? 我用.innerHTML="暂无数据"可以实现,但是这样破坏了echarts自己生成的canvas,当有数据的时候需要重新执行init()方法。所以当我有很多个chart要管理的时候情况会变得很复杂。

Version & Environment [版本及环境]

  • ECharts version [ECharts 版本]: echarts 3
  • Browser version [浏览器类型和版本]: chrome
  • OS Version [操作系统类型和版本]: ubuntu 16.04

Expected behaviour [期望结果]

期望echarts3提供noDataLoadingOption接口。

ECharts option [ECharts配置项]

option = {

}

Other comments [其他信息]

pbnull avatar Dec 30 '16 07:12 pbnull

暂无数据这个逻辑其实我们不太好判断,因为有可能用户只是想显示一个组件,所以建议在接收到数据的时候根据业务判断上会否是无数据,没数据可以覆盖一层 div,或者通过 http://echarts.baidu.com/option.html#graphic 组件加入自定义图形显示没有数据

pissang avatar Dec 30 '16 08:12 pissang

通过 graphic 添加文字“暂无数据” , 实现了需求,就是 图表画出来了一部分xy轴,还有 title ,看着有点怪

sichuyoudang avatar May 08 '17 08:05 sichuyoudang

其实只是想显示些文字在上面,或者showLoading 时不要动画只要文字也可以。

sunriseyuen avatar Jun 02 '17 11:06 sunriseyuen

@pbnull 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)
    };

tongxuehello avatar Sep 09 '17 04:09 tongxuehello

其实只是想显示些文字在上面,或者showLoading 时不要动画只要文字也可以。

我也是这个需要大佬有不展示转圈的方案吗?

hduhdc avatar Jun 05 '19 06:06 hduhdc

myChart3.showLoading({ text: '暂无数据', color: '#ffffff', textColor: '#8a8e91', maskColor: 'rgba(255, 255, 255, 0.8)', } );

把动画效果color设为和你背景一致,这样就可以"隐藏"动画效果,只会显示暂无数据文字,比如我这里背景颜色是白色,我将动画效果color就设为#ffffff

yangnzhi avatar Jun 27 '19 09:06 yangnzhi

通过 graphic 添加文字“暂无数据” , 实现了需求,就是 图表画出来了一部分xy轴,这样肯定有问题 的,希望改进

arcsin1 avatar Apr 15 '20 07:04 arcsin1