echarts环形图内部圆,外部圆形以及阴影设置

这篇具有很好参考价值的文章主要介绍了echarts环形图内部圆,外部圆形以及阴影设置。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

环形图

echarts环形图加阴影,笔记,echarts,vue.js,前端,javascript,Powered by 金山文档

修改图例自定义icon

echarts环形图加阴影,笔记,echarts,vue.js,前端,javascript,Powered by 金山文档

完整代码图文章来源地址https://www.toymoban.com/news/detail-559066.html

  Chart1() { // 折算价值户新增构成
      let chartDom = document.getElementById('main');
      let myChart = this.$echarts.init(chartDom);
      let option;
      option = {
        // 设置占比图颜色
        color:['#FFA500','#66CDAA','    #1E90FF','    #E8E8E8'],
        tooltip: { //提示框
          trigger: 'item',
          formatter: '{b} : <br/> {c} ({d}%)'
        },
        title:[ // 中心换行标题
          {
            text: "总计",
            left: '24%',
            top: '43%',
            textStyle: {
              color: 'black',
              fontSize: 12,
              fontWeight: "400",
              color:'#1787ff'
            }
          },
          {
            text: '100%',
            left: '22%',
            top: '35%',
            textStyle: {
              color: 'black',
              fontSize: 14,
              fontWeight: "400",
              color:'#1787ff',
              fill: 'red',
            }
          }
        ],
        legend: {// 图例
          orient: 'vertical',//horizontal 水平显示,vertical 垂直显示
          right: 0,
          top: 20,
          bottom: 20,
          itemWidth:10,//图例宽度
          itemHeight: 10,
          itemGap: 35,//图例之间间距
        },
        series: [
          {
            name: '占比',
            startAngle: 180,
            label: {// 点击展示方式
              show: false,
            },
            type: 'pie',
            radius: ['35%', '60%'],// 饼图大小设置
            roseType: 'area',
            avoidLabelOverlap: true,// 是否启用防止标签重叠策略
            labelLine: { // z折线连接的标题
              show: false
            },
            center: ['30%', '40%'],//饼图位置
            data: [
              { value: 735, name: '25% 彭浦支行' },
              { value: 735, name: '25% 闸北支行' },
              { value: 580, name: '40% 芷江支行' },
              { value: 384, name: '10% 其他' }
            ]
          },
          {
            name:'中心圆',
            radius: ['0%', '30%'],
            center: ['30%', '40%'],
            type: 'pie',
            color:"white",  //内圆颜色
            itemStyle: { 
              normal: {
                // 设置阴影
                shadowBlur: 30,
                shadowColor: 'rgba(147, 147, 147,0.3)', 
                shadowOffsetX: 0,
                shadowOffsetY: 7
              }
            },
            label: {
              normal: {
                  show: false
              },
              emphasis: {
                  show: false
              }
            },
            labelLine: {
                normal: {
                  show: false
                },
                emphasis: {
                  show: false
                }
            },
            animation: false,
            tooltip: {
              show: false
            },
            data: [{
              value: 1,
            }],
        },
        {
          name: '外边框',
          type: 'pie',
          color:"white",  //内圆颜色
          clockWise: false, //顺时加载
          hoverAnimation: false, //鼠标移入变大
          center: ['30%', '40%'],
          radius: ['60%', '65%'],
          itemStyle: { 
            normal: {
              // 设置阴影
              shadowBlur: 30,
              shadowColor: 'rgba(147, 147, 147,0.3)', 
              shadowOffsetX: 10,
              shadowOffsetY: 7
            }
          },
          label: {
            normal: {
                show: false
            }
          },
          data: [{
            value: 9,
            name: '',
            itemStyle: {
                normal: { //可以设置样式
                  // borderWidth: 2,
                  // borderColor: '#2ec7c9'
                }
            }
          }]
        },
        ]
      };
      option && myChart.setOption(option);
    },

柱状图

echarts环形图加阴影,笔记,echarts,vue.js,前端,javascript,Powered by 金山文档
Chart2(){
      let chartDom = document.getElementById('main2');
      let myChart = this.$echarts.init(chartDom);
      let category = ['彭浦支行', '闸北支行', '芷江支行', '其他'];
      // let barData = [310, 212, 118, 81];
      let option;
      option = {
        tooltip: {
          trigger: 'item',
        },
        legend: {
          x:'center',
          y:'bottom',
          icon: "circle", // 修改形状
          temHeight: 1, // 修改icon图形大小
          itemGap: 14, // 修改间距
          textStyle: {
            fontSize: 10,
            color: "#333",
          },
        },
        grid: {
          left: '3%',
          right: '4%',
          top: '2%',
          containLabel: false
        },
        xAxis: {
          type: 'value',
          axisLine: {
            show: false
          },
          axisTick: {
            show: false
          },
          axisLabel: {
            show: false 
          },
          splitLine:{ // 背景线条
            show:true,
            lineStyle:{
              color:'    #d6d6d6',
              width:0.2,// 线条宽
            }
          }
        },
        yAxis: [
          {
            type: 'category',
            show:false,
            inverse:true,
            data: category,
            axisLine: {
              show: false
            },
            axisTick: {
              show: false
            }
          },
       ],
        series: [
        {
          name: '彭浦支行',
          data: [310, null, null,  null],
          type: 'bar',
          barWidth:10,// 柱子宽度
          stack: 'Mon',
          itemStyle: {
            normal: {
              barBorderRadius: 17,
              color: new this.$echarts.graphic.LinearGradient(0, 0, 1, 0, [
              {
                offset: 0,
                color: '#FFD700'
              }, {
                offset: 1,
                color: '#FFA500'
              }]),
            },
          },
          label: {
            show: true,
            position: 'right',
            formatter: '{c}',
          }
        },
        {
          name: '闸北支行',
          data: [null, 212, null,  null],
          type: 'bar',
          stack: 'Mon',
          itemStyle: {
            normal: {
              barBorderRadius: 17,
              color: new this.$echarts.graphic.LinearGradient(0, 0, 1, 0, [
              {
                offset: 0,
                color: '#87CEFF'
              }, {
                offset: 1,
                color: '#5284DE'
              }]),
            }
          },
          label: {
            show: true,
            position: 'right',
            formatter: '{c}',
          }
        },
        {
          name: '芷江支行',
          data: [null, null, 118, null],
          type: 'bar',
          stack: 'Mon',
          itemStyle: {
            normal: {
              barBorderRadius: 17,
              //这里是颜色
              color: new this.$echarts.graphic.LinearGradient(0, 0, 1, 0, [
              {
                offset: 0,
                color: '#76EEC6'
              }, {
                offset: 1,
                color: '#66CDAA'
              }]),
            }
          },
          label: {
            show: true,
            position: 'right',
            formatter: '{c}',
          }
        },
        {
          name: '其他',
          data: [null, null, null,  81],
          type: 'bar',
          stack: 'Mon',
          itemStyle: {
            normal: {
              barBorderRadius: 17,
              //这里是颜色
              color: new this.$echarts.graphic.LinearGradient(0, 0, 1, 0, [
              {
                offset: 0,
                color: '#F5F5F5'
              }, {
                offset: 1,
                color: '#E8E8E8'
              }]),
            }
          },
          label: {
            show: true,
            position: 'right',
            formatter: '{c}',
          }
        },
        ]
      };

      option && myChart.setOption(option);
    },

半圆图

echarts环形图加阴影,笔记,echarts,vue.js,前端,javascript,Powered by 金山文档
Chart3(){
      let chartDom = document.getElementById('main3');
      let myChart = this.$echarts.init(chartDom);
      let option;
      // 进度百分比
      let value = 95
      option = {
        title: [{
            text: value + '%',
            left: 'center',
            top: '40%',
            textStyle: {
              color: 'rgba(64, 140, 255, 1)',
              fontSize: 20
            }
        }, {
            text: '目标完成率',
            left: 'center',
            top: '55%',
            textStyle: {
              color: 'black',
              fontSize: 10,
              color:'grey'
            }
        }],
        legend: {
          bottom:'20',
          itemWidth:15,
          itemHeight: 10,
          itemGap: 45,//图例间距
          data: ["价值户新增数:45个", "目标总数:90个", ],
        },
        angleAxis: {
          show: false,
          // 后面的180表示圆环的跨越的角度, 如max设置为100*360/270,startAngle设置为-135
          max: 100 * 360 / 180,
          type: 'value',
          startAngle: 180,
          splitLine: {
            show: false
          }
        },
        // 修改环形的宽度
        barMaxWidth: 15,
        radiusAxis: {
          show: false,
          type: 'category'
        },
        polar: {
          // 设置环形的位置
          center: ['50%', '60%'],
          // 设置环形大小
          radius: '150%'
        },
        series:[
          {
            name:'价值户新增数:45个',
            color: 'rgba(23, 135, 255, 1)',
            type: 'bar',
            roundCap: true, // 开启圆角
            data: [
              { 
                value: value,
                itemStyle: {
                  normal: {
                    opacity: 1,
                    color: new this.$echarts.graphic.LinearGradient(0, 0, 1, 0, [
                      {
                        offset: 0,
                        color: '#25BFFF'
                      }, {
                        offset: 1,
                        color: '#5284DE'
                      }]),
                    shadowColor: '#2A95F9'
                  }
                }
              }
            ],
            barGap: '-100%',
            coordinateSystem: 'polar',
            z: 3
        }, {
            name:'目标总数:90个',
            color: 'rgba(244, 249, 253, 1)',
            type: 'bar',
            roundCap: true,// 开启圆角
            data: [{
                value: 100,
                itemStyle: {
                  // 这里是环形底色
                  color: 'rgba(244, 249, 253, 1)',
                  borderWidth: 0
                }
            }],
            barGap: '-100%',
            coordinateSystem: 'polar',
            z: 1
        }]
      }
      option && myChart.setOption(option);

    },

折线图

echarts环形图加阴影,笔记,echarts,vue.js,前端,javascript,Powered by 金山文档
Chart4() {
      let chartDom = document.getElementById('main4');
      let myChart = this.$echarts.init(chartDom);
      let option;
      option = {
        tooltip: { //提示框
       //触发类型;轴触发,axis则鼠标hover到一条柱状图显示全部数据,item则鼠标hover到折线点显示相应数据,
          trigger: 'item', 
          formatter:'{b}<br/>价值户新增:{c}',
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,// 坐标轴两边是不是留白
          data: ['04/28', '04/30', '05/02', '05/04','05/08','05/10','5/20'],
          axisLine: {//坐标系
            show: true,
            lineStyle:{ //x坐标系字体样式
              color:'#E8E8E8',
              width:0.5
            }
          },
          axisLabel: {
            interval:1,//0代表显示所有x轴标签显示,1不显示全
            color:'grey'//x轴字体颜色
          },
          axisTick: { // 刻度线
            show: false,
          },
        },
        yAxis: {
          type: 'value',
          axisLabel:{//字体
            color:'grey'
          },
          axisLine: {//y轴线
            show: true,
            lineStyle:{
              color:'#BEBEBE'
            }
          },
          axisTick: {//y刻度线
              show: false
          },
          splitLine: { // 背景线 分割线
            show: true,
            lineStyle:{
              type:'dashed',
              color:'    #F5F5F5'
            }
          }
        },
        series: [
          {
            data: [13, 26, 30, 66, 30,8,40],
            type: 'line',
            smooth: true,//显示平滑曲线
            lineStyle:{
              color:'#00BFFF' //折线颜色
            },
            itemStyle : { //折线点颜色
              normal : {
                color:'#00BFFF'
              }
            },
            areaStyle: { //区域渐变色
              normal: {
                color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
                  {
                    offset: 0,
                    color: '#87CEFF'
                  }, {
                    offset: 1,
                    color: '#ffffff'
                  }
                ]),
              }
            },
          }
        ]
      };

      option && myChart.setOption(option);

    }

到了这里,关于echarts环形图内部圆,外部圆形以及阴影设置的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【Echarts】Echarts饼图样式-添加内圈阴影达到立体效果

    实现思想: 最终效果: 1.在series中添加内圈饼图 2.保持内圈高亮,达到阴影效果 完整script代码:

    2024年01月23日
    浏览(33)
  • echarts圆形统计图与柱状图结合

    1、先展示效果图 2、直接上代码,copy代码进行调试便会懂(导入echarts插件看之前的文章)

    2023年04月11日
    浏览(20)
  • 使用Echarts饼图时将图例图标变成圆形

    在echarts官方实例里,图例都是方形,今天碰到需求,需要是圆形图标,在此记录一下 直接在legend中设置 icon:‘circle’

    2024年02月16日
    浏览(31)
  • 【ECharts】环形图、饼状图

    目录 color设置的颜色 环形渐变色 圆环中间显示文字 悬浮显示中间文字 悬浮显示中间文字,默认显示第一个 循环高亮饼图块 label文字过长重叠 label和饼图一致 label展示位置 内容为0仍然显示扇区 圆角环形图 仿3D环形图 label带小圆点 label超出边界显示不全 百分比圆环图 延时动

    2023年04月17日
    浏览(25)
  • echarts如何实现3D饼图(环形图)?

    一、实现的效果 二、具体步骤 1.安装依赖 npm install echarts  2.引入echarts import * as echarts from \\\'echarts\\\';  注意:这里需要用到echarts-gl,必须单独引入才可以 import \\\'echarts-gl\\\'; 3.echarts部分代码 我知道这部分内容很多,但只要cv去用就可以了, getParametricEquation 这个函数不用改(我也不

    2024年03月28日
    浏览(75)
  • 记录--ECharts — 饼图相关功能点(内环、外环、环形间隔、环形文字、轮播动画)

    记录一下在公司遇到的一些功能,以及相关实现 以上的内容我花了一周时间去实现的,自己也觉得时间很长,但主要因为很少使用ECharts,导致使用的过程中大部分的时间都在查文档。 对于上面的这些功能点,其实算是写了两遍吧,这周一开了个Code Review,因为涉及到公共组

    2024年02月05日
    浏览(29)
  • uniapp app端 echarts 设置tooltip的formatter不生效问题以及解决办法

    需求一: y轴数据处理不同数据增加不同单位 需求二: 自定义图表悬浮显示的内容 需求一:实现方式 在yAxis里面添加formatter 问题 : formatter 设置未生效 h5可以正常展示能看到单位,但是app端不生效 app端不生效是因为: 在app端,回调函数无法从renderjs外传递,上面的设置使用

    2024年02月14日
    浏览(40)
  • Echarts饼图4.0(3D环形图、包含透明效果)

    参考链接:https://blog.csdn.net/weixin_41326021/article/details/120195920 原始文件链接:https://download.csdn.net/download/Y1914960928/87884880

    2024年02月15日
    浏览(31)
  • echarts 饼图 环形图 lable添加下划线

         

    2024年02月09日
    浏览(33)
  • vue 使用echarts实现3D饼图和环形图

    记录一下echarts实现3d饼图和环形图功能## 标题 实现效果 首先第一步安装echarts和echarts-gl echarts-gl安装最新版本可能会有异常,建议安装\\\"echarts-gl\\\": \\\"^1.1.2\\\"版本 第二步在vue文件中引入 第三步我这里把实现3d饼图的代码给封装一下,如下: 第四步 vue文件内使用 饼图的实现 如果对

    2024年02月12日
    浏览(44)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包