Echarts使用笔记

echarts没有数据时显示暂无数据

if(resp.data && resp.data.length > 0){
    ... 初始图表
}else{
    this.$nextTick(()=>{
        this.$refs.electricityTrendAndPredictBar.innerHTML = "暂无数据";
        this.$refs.electricityTrendAndPredictBar.style.textAlign = "center";
        this.$refs.electricityTrendAndPredictBar.style.lineHeight = "350px";
        this.$refs.electricityTrendAndPredictBar.removeAttribute('_echarts_instance_');
    })
}

参考博客:https://www.jianshu.com/p/ea7909f7b65c

echarts标题(legend)过多时分页显示

//图例--折线提示提示
legend: {
    x: 'center',
    y: '20',
    type: 'scroll', //分页类型
    orient: "horizontal", // horizontal 横向排列 vertical 纵向排列
    borderColor: '#6699FF', //边框颜色
    textStyle: {
        color: '#1e90ff' // 图例文字颜色
    },
    data: []
},

echarts自定义tooltip显示

tooltip: {
  trigger: "axis",
  axisPointer : {            // 坐标轴指示器,坐标轴触发有效
    type : 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
  },
  formatter : function(params){
    let tip = params[0].name ;
    for(let i = 0;i < params.length; i++) {
      if(i === params.length - 1){
        tip += '<br>' + params[i].marker + " " + params[i].seriesName+': ' + params[i].value + '%';
      }else{
        tip += '<br>' + params[i].marker + " " + params[i].seriesName+': ' + params[i].value;
      }
    }
    return tip;
  }
},

- End -
- 个人学习笔记 -
- 仅供参考 -

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Maggieq8324

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值