vue eCharts进度条

在这里插入图片描述

1.在vue项目里面

<div  id="myDoubtBankListEcharts3" class="myecharts" style="width: 100%;height: 70%;display:inline-block;"></div>


import * as echarts from "echarts";


let myDoubtBankListEcharts3 = echarts.init(
        document.getElementById("myDoubtBankListEcharts3")
      );
      let ratioNumber = [80];
      ratioNumber = [this.doubtHandVO.doubtHandProgress];
      myDoubtBankListEcharts3.setOption({
        grid: {
          left: "5%",
          right: "5%",
          bottom: "5%",
          top: "10%",
          containLabel: true,
        },
        backgroundColor: "transparent",
        // xAxis: {
        //     show: false,
        //     type: 'value',
        //     max: 100,
        // },
        xAxis: [
          {
            type: "value",
            axisLabel: {
              margin: 5,
              color: "#fff",
              formatter: function (val) {
                return val + "";
              },
              textStyle: {
                fontSize: "0",
              },
            },
            min: 0,
            max: 100, // 计算最大值
            // interval: max / 5, //  平均分为5份
            splitNumber: 15,
            splitLine: {
              show: false,
              lineStyle: {
                color: "#fff",
              },
            },
            axisLine: {
              show: false,
              lineStyle: {
                color: "#fff",
                width: 1,
                opacity: 0.3,
              },
            },
            axisTick: {
              show: false,
            },
          },
          {
            type: "value",
            axisLabel: {
              show: false,
            },
            min: 0,
            max: 100, // 计算最大值
            interval: 100 / 10, //  平均分为5份
            splitNumber: 10,
            splitLine: {
              show: false,
              lineStyle: {
                type: "dashed",
                color: "#D8D8D8",
              },
            },
            axisLine: {
              show: false,
              lineStyle: {
                color: "#fff",
              },
            },
            axisTick: {
              show: false,
            },
          },
        ],
        yAxis: [
          {
            type: "category",
            inverse: true,
            axisLabel: {
              show: false,
              textStyle: {
                fontSize: "12",
                color: "#03fcfe",
              },
            },
            splitLine: {
              show: false,
            },
            axisTick: {
              show: false,
            },
            axisLine: {
              show: false,
            },
            data: ["比率"],
          },
          {
            type: "category",
            inverse: true,
            axisTick: "none",
            axisLine: "none",
            show: false,
            data: ratioNumber, //80
          },
        ],
        series: [
          {
            type: "bar",
            showBackground: false,
            xAxisIndex: 0,
            backgroundStyle: {
              color: "transparent",
              borderRadius: 30,
              z: 1212,
            },
            label: {
              show: true,
              position: "right",
              formatter: "{@score}%",
              textStyle: {
                color: "rgb(25, 142, 248)",
                fontSize: "16",
              },
            },
            itemStyle: {
              normal: {
                borderRadius: 20,
                color: "rgb(25, 142, 248)",
              },
            },
            barWidth: 20,
            data: ratioNumber, //80
            z: 12212,
          },
          {
            type: "bar",
            showBackground: false,
            xAxisIndex: 1,
            barGap: "-100%",
            backgroundStyle: {
              color: "transparent",
              borderRadius: 30,
              z: 1212,
            },
            label: {
              show: false,
              position: "right",
              formatter: "{@score}%",
              textStyle: {
                color: "#fff",
                fontSize: "12",
              },
            },
            itemStyle: {
              normal: {
                borderRadius: 20,
                color: "rgba(215, 236, 255,.4)",
              },
            },
            barWidth: 20,
            data: [100],
            z: 12210,
          },
        ],
      });
      window.addEventListener("resize", function () {
        myDoubtBankListEcharts3.resize();
      });

2.在echarts调试-代码编辑

let ratioNumber = [80];
     
     option = {
        grid: {
          left: "5%",
          right: "5%",
          bottom: "5%",
          top: "10%",
          containLabel: true,
        },
        backgroundColor: "transparent",
        // xAxis: {
        //     show: false,
        //     type: 'value',
        //     max: 100,
        // },
        xAxis: [
          {
            type: "value",
            axisLabel: {
              margin: 5,
              color: "#fff",
              formatter: function (val) {
                return val + "";
              },
              textStyle: {
                fontSize: "0",
              },
            },
            min: 0,
            max: 100, // 计算最大值
            // interval: max / 5, //  平均分为5份
            splitNumber: 15,
            splitLine: {
              show: false,
              lineStyle: {
                color: "#fff",
              },
            },
            axisLine: {
              show: false,
              lineStyle: {
                color: "#fff",
                width: 1,
                opacity: 0.3,
              },
            },
            axisTick: {
              show: false,
            },
          },
          {
            type: "value",
            axisLabel: {
              show: false,
            },
            min: 0,
            max: 100, // 计算最大值
            interval: 100 / 10, //  平均分为5份
            splitNumber: 10,
            splitLine: {
              show: false,
              lineStyle: {
                type: "dashed",
                color: "#D8D8D8",
              },
            },
            axisLine: {
              show: false,
              lineStyle: {
                color: "#fff",
              },
            },
            axisTick: {
              show: false,
            },
          },
        ],
        yAxis: [
          {
            type: "category",
            inverse: true,
            axisLabel: {
              show: false,
              textStyle: {
                fontSize: "12",
                color: "#03fcfe",
              },
            },
            splitLine: {
              show: false,
            },
            axisTick: {
              show: false,
            },
            axisLine: {
              show: false,
            },
            data: ["比率"],
          },
          {
            type: "category",
            inverse: true,
            axisTick: "none",
            axisLine: "none",
            show: false,
            data: ratioNumber, //80
          },
        ],
        series: [
          {
            type: "bar",
            showBackground: false,
            xAxisIndex: 0,
            backgroundStyle: {
              color: "transparent",
              borderRadius: 30,
              z: 1212,
            },
            label: {
              show: true,
              position: "right",
              formatter: "{@score}%",
              textStyle: {
                color: "rgb(25, 142, 248)",
                fontSize: "16",
              },
            },
            itemStyle: {
              normal: {
                borderRadius: 20,
                color: "rgb(25, 142, 248)",
              },
            },
            barWidth: 20,
            data: ratioNumber, //80
            z: 12212,
          },
          {
            type: "bar",
            showBackground: false,
            xAxisIndex: 1,
            barGap: "-100%",
            backgroundStyle: {
              color: "transparent",
              borderRadius: 30,
              z: 1212,
            },
            label: {
              show: false,
              position: "right",
              formatter: "{@score}%",
              textStyle: {
                color: "#fff",
                fontSize: "12",
              },
            },
            itemStyle: {
              normal: {
                borderRadius: 20,
                color: "rgba(215, 236, 255,.4)",
              },
            },
            barWidth: 20,
            data: [100],
            z: 12210,
          },
        ],
      };


    myChart.setOption(option);
      window.addEventListener("resize", function () {
        myChart.resize();
      });

3.在echarts调试-完整代码

import * as echarts from 'echarts';

var chartDom = document.getElementById('main');
var myChart = echarts.init(chartDom);
var option;

let ratioNumber = [80];

option = {
  grid: {
    left: '5%',
    right: '5%',
    bottom: '5%',
    top: '10%',
    containLabel: true
  },
  backgroundColor: 'transparent',
  // xAxis: {
  //     show: false,
  //     type: 'value',
  //     max: 100,
  // },
  xAxis: [
    {
      type: 'value',
      axisLabel: {
        margin: 5,
        color: '#fff',
        formatter: function (val) {
          return val + '';
        },
        textStyle: {
          fontSize: '0'
        }
      },
      min: 0,
      max: 100, // 计算最大值
      // interval: max / 5, //  平均分为5份
      splitNumber: 15,
      splitLine: {
        show: false,
        lineStyle: {
          color: '#fff'
        }
      },
      axisLine: {
        show: false,
        lineStyle: {
          color: '#fff',
          width: 1,
          opacity: 0.3
        }
      },
      axisTick: {
        show: false
      }
    },
    {
      type: 'value',
      axisLabel: {
        show: false
      },
      min: 0,
      max: 100, // 计算最大值
      interval: 100 / 10, //  平均分为5份
      splitNumber: 10,
      splitLine: {
        show: false,
        lineStyle: {
          type: 'dashed',
          color: '#D8D8D8'
        }
      },
      axisLine: {
        show: false,
        lineStyle: {
          color: '#fff'
        }
      },
      axisTick: {
        show: false
      }
    }
  ],
  yAxis: [
    {
      type: 'category',
      inverse: true,
      axisLabel: {
        show: false,
        textStyle: {
          fontSize: '12',
          color: '#03fcfe'
        }
      },
      splitLine: {
        show: false
      },
      axisTick: {
        show: false
      },
      axisLine: {
        show: false
      },
      data: ['比率']
    },
    {
      type: 'category',
      inverse: true,
      axisTick: 'none',
      axisLine: 'none',
      show: false,
      data: ratioNumber //80
    }
  ],
  series: [
    {
      type: 'bar',
      showBackground: false,
      xAxisIndex: 0,
      backgroundStyle: {
        color: 'transparent',
        borderRadius: 30,
        z: 1212
      },
      label: {
        show: true,
        position: 'right',
        formatter: '{@score}%',
        textStyle: {
          color: 'rgb(25, 142, 248)',
          fontSize: '16'
        }
      },
      itemStyle: {
        normal: {
          borderRadius: 20,
          color: 'rgb(25, 142, 248)'
        }
      },
      barWidth: 20,
      data: ratioNumber, //80
      z: 12212
    },
    {
      type: 'bar',
      showBackground: false,
      xAxisIndex: 1,
      barGap: '-100%',
      backgroundStyle: {
        color: 'transparent',
        borderRadius: 30,
        z: 1212
      },
      label: {
        show: false,
        position: 'right',
        formatter: '{@score}%',
        textStyle: {
          color: '#fff',
          fontSize: '12'
        }
      },
      itemStyle: {
        normal: {
          borderRadius: 20,
          color: 'rgba(215, 236, 255,.4)'
        }
      },
      barWidth: 20,
      data: [100],
      z: 12210
    }
  ]
};

myChart.setOption(option);
window.addEventListener('resize', function () {
  myChart.resize();
});

option && myChart.setOption(option);

4,关于echarts的安装和使用

请参考我的另一篇文章:
https://blog.csdn.net/ingenuou_/article/details/123179231?spm=1001.2014.3001.5502

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值