ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Echart柱状图-柱子顶部显示数值/显示图标

2022-01-09 21:32:46  阅读:472  来源: 互联网

标签:Echart IMG image value height width 柱状图 40 图标


柱子顶部显示数值效果

在这里插入图片描述
在这里插入图片描述

柱子顶部显示数值+图标

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

import EchartInit from '@/components/EchartInit';

const IMG = [
  'https://scpic.chinaz.net/Files/pic/icons128/8328/h1.png',
  'https://scpic.chinaz.net/Files/pic/icons128/8319/w2.png',
  'https://img0.baidu.com/it/u=3119542616,1165410720&fm=26&fmt=auto',
  'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F1113%2F061H0102U6%2F20061G02U6-12-1200.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1644314407&t=aa49089b06c80ff5c9e3404d3ec85382',
  'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2Ftp09%2F21042G339292K3-0-lp.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1644314407&t=e3a817c74754fdade94aa51858689928',
  'https://scpic.chinaz.net/Files/pic/icons128/8308/d5.png',
  'https://scpic.chinaz.net/Files/pic/icons128/8304/e7.png',
  'https://sc.chinaz.com/tubiao/220108527280.htm',
]
export default function BarEchart(props: any) {

  const options = {
    xAxis: {
      type: 'category',
      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
      axisLabel: {
        formatter: (value) => {
         return value + '\n'+'{' + value + '| }';
        },
        rich: {
          Mon: {
            height: 40,
            width: 40,
            backgroundColor: {
              image: IMG[0]
            }
          },
          Tue: {
            height: 40,
            width: 40,
            backgroundColor: {
              image: IMG[1]
            }
          },
          Wed: {
            height: 40,
            width: 40,
            backgroundColor: {
              image: IMG[2],
            },
          },
          Thu: {
            height: 40,
            width: 40,
            backgroundColor: {
              image: IMG[3],
            },
          },
          Fri: {
            height: 40,
            width: 40,
            backgroundColor: {
              image: IMG[4],
            },
          },
          Sat: {
            height: 40,
            width: 40,
            backgroundColor: {
              image: IMG[5],
            },
          },
          Sun: {
            height: 40,
            width: 40,
            backgroundColor: {
              image: IMG[6],
            },
          }
        }
      }
    },
    yAxis: {
      type: 'value'
    },
    series: [
      {
        data: [120, 200, 150, 80, 70, 110, 130],
        type: 'bar',
        label: {
          show: true,
          position: 'top',
          formatter: (value,index)=> {
            console.log('value',value,value?.dataIndex);  
            return value?.value + '{'+ 'icon' + '| }';
          },
          rich: {
            icon : {
              height: 20,
              width: 20,
              backgroundColor: {
                image: IMG[0]
              }
            }
          }
        },

      }
    ]
  };

  return (
    <div style={{height :300, width:'100%'}}>
      <EchartInit options={options} />
    </div>
  )
}

标签:Echart,IMG,image,value,height,width,柱状图,40,图标
来源: https://blog.csdn.net/weixin_40119412/article/details/122399505

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有