echarts中当没有数据时

正常显示时:
echarts中当没有数据时_第1张图片

当没有数据时,不能显示为空,应该这样显示
echarts中当没有数据时_第2张图片
代码示例:

async getRun(sid, pid, sd, ed) {
    this.chartCountList = [];
    this.chartDateList = [];
    const { result: res }: any = await this.str.getSource3(sid, pid, sd, ed);
    console.log(res);
    if ( res.items.length !== 0) {
      // tslint:disable-next-line:prefer-for-of
      for ( let i = 0; i < res.items.length; i++ ) {
        this.chartCountList.push( Number(res.items[i].num) );
        this.chartDateList.push(this.datePipe.transform( res.items[i].tm, 'yyyy-MM-dd' ));
      }
    } elae {
	this.chartDateList = this.startDate2;
	this.chartCountList = 0;
	}
  }

关键在于:当接口返回数据为空时,就把进行收索的开始时间赋值给y坐标,并给y轴赋值数据为0

你可能感兴趣的:(echarts,angular)