溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

vue+echarts怎么實現條紋柱狀橫向圖

發布時間:2022-04-02 11:11:19 來源:億速云 閱讀:354 作者:iii 欄目:開發技術

這篇“vue+echarts怎么實現條紋柱狀橫向圖”文章的知識點大部分人都不太理解,所以小編給大家總結了以下內容,內容詳細,步驟清晰,具有一定的借鑒價值,希望大家閱讀完這篇文章能有所收獲,下面我們一起來看看這篇“vue+echarts怎么實現條紋柱狀橫向圖”文章吧。

實現效果:

vue+echarts怎么實現條紋柱狀橫向圖

<template>
  <div id="BusinessTop5Chart" ></div>
</template>
<script>
import { getNoteMatters } from '@/api/government';
const colors = [
   'rgba(248, 75, 110, 1)',
   'rgba(239, 142, 47, 1)',
   'rgba(234, 202, 4, 1)',
   'rgba(79, 224, 255, 1)',
   'rgba(106, 196, 255, 1)',
 ];
export default {
  data() {
    return {
      list: [],
      list1: [],
      list2: [],
      Top5ListName: [],
      Top5ListValue:[]
    };
  },
  mounted() {
    this.getNoteMatters();
  },
  methods: {
    initMap() {
      var myChart = this.$echarts.init(document.getElementById('BusinessTop5Chart'));
      const option = {
        grid: {
          top: 20,
          bottom: 30,
          left: 10,
          right: 150,
          containLabel: true,
        },
        tooltip: {
          show: true,
          trigger: 'axis',
          axisPointer: {
            type: 'shadow',
          },
        },
        xAxis: {
          type: 'value',
          splitLine: {
            show: false,
          },
          axisLine: {
            show: false,
          },
          axisLabel: {
            show: false,
          },
          axisTick: {
            show: false,
          },
          position: 'top',
        },
        yAxis: {
          type: 'category',
          data: this.Top5ListName,
          inverse: true, //倒敘
          axisLine: {
            show: false,
          },
          axisTick: {
            show: false,
          },
          axisLabel: {
            textStyle: {
              color: 'rgba(255,255,255,0.85)',
              fontSize: 14,
              fontFamily: 'TencentSans',
            },
            padding: [0, 0, 20, 0],
            inside: true,
            verticalAlign: 'bottom',
          },
        },
        series: [
          {
            type: 'bar',
            barGap: '-90%',
            barMaxWidth: 14,
            z: 0,
            label: {
              normal: {
                show: false,
                position: 'right',
                fontSize: 14,
                offset: [16, 0],
              },
            },
            data: this.list,
          },
          {
            type: 'bar',
            barGap: '-90%',
            barMaxWidth: 14,
            itemStyle: {
              color: 'rgba(26, 49, 99, 0.5)',
            },
            tooltip: {
              show: false,
            },
            data: this.list1,
          },
          {
            type: 'pictorialBar',
            symbolRepeat: 'fixed',
            symbolMargin: 4,
            symbol: 'rect',
            symbolClip: true,
            symbolSize: [1, 14],
            symbolPosition: 'start',
            itemStyle: {
              color: 'rgba(0,0,0,1)',
            },
            data: this.list2,
          },
        ],
      };
      myChart.setOption(option);
    },
    getNoteMatters() {
      getNoteMatters().then((res) => {
        const { status, data } = res;
        const { businessTpo5 } = JSON.parse(data);
        if (status === 200) {
        // this.Top5ListName=[
        //      {0: "三亞市稅務局", 
        //       1: "三亞市市場監督管理局", 
        //       2: "三亞市公安局", 
        //       3: "三亞市郵政管理局", 
        //       4: "三亞市社會保險服務中心窗口"}]
          this.Top5ListName = businessTpo5.map((item) => {
            return item.agencies;
          });
        // this.Top5ListValue=[{0: 189354, 1: 56933, 2: 13267, 3: 10979, 4: 9054}]
          this.Top5ListValue = businessTpo5.map((item) => {
            return Number(item.num);
          });
          const max = Math.max.apply(null, this.Top5ListValue);
       // this.list=[{itemStyle:
       //         color: "rgba(248, 75, 110, 1)"
       //         name: "三亞市稅務局"
       //         num: "189354"
       //         rate: "57.03%"
       //         value: 189354}]
          this.list = businessTpo5.map((item, index) => {
            let obj = {
              name: item.agencies,
              value: Number(item.num),
              num: item.num,
              rate: item.rate,
              itemStyle: {
                color: colors[index],
              },
            };
            return obj;
          });
       // this.list1=[
       // label:{
       // normal:{
       // color: colors[index],
       // fontSize: 14
       // position: "right"
       // show: true
       // offset:[16,0]
       // name: "三亞市稅務局"
       // formatter(){return(item.num+'單位'+''+item.rate)}
       // rate: "57.03%"
       // value: 189354}}
          this.list1 = businessTpo5.map((item, index) => {
            let obj = {
              name: item.agencies,
              value: max,
              label: item.num,
              rate: item.rate,
              label: {
                normal: {
                  show: true,
                  position: 'right',
                  fontSize: 14,
                  color: colors[index],
                  offset: [16, 0],
                  formatter() {
                    return (
                      item.num + '件' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + item.rate
                    );
                  },
                },
              },
            };
            return obj;
          });
      // this.list2=[{label: "189354"
      // name: "三亞市稅務局"
      // rate: "57.03%"
      // value: 189354}]    
        this.list2 = businessTpo5.map((item) => {
            let obj = {
              name: item.agencies,
              value: Number(item.num),
              label: item.num,
              rate: item.rate,
            };
            return obj;
          });
        }
        this.initMap();
      });
    },
  },
};
</script>

以上就是關于“vue+echarts怎么實現條紋柱狀橫向圖”這篇文章的內容,相信大家都有了一定的了解,希望小編分享的內容對大家有幫助,若想了解更多相關的知識內容,請關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女