欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue+echart實現(xiàn)雙柱狀圖

 更新時間:2021年09月05日 10:47:58   作者:知命者夏洛特  
這篇文章主要為大家詳細(xì)介紹了vue+echart實現(xiàn)雙柱狀圖,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了vue+echart實現(xiàn)雙柱狀圖的具體代碼,供大家參考,具體內(nèi)容如下

效果圖:

一、安裝

版本號建議安裝"echarts": "^4.8.0”,其它版本init會報錯

1、 首先需要安裝echarts依賴包

npm install --save echarts@4.8.0

2、 或者使用國內(nèi)的淘寶鏡像:

npm install -g cnpm --registry=https://registry.npm.taobao.org
<template>
  <div class="echarts_con">
    <div
      class="echarts_main"
      ref="dialog_root"
      title="節(jié)點指標(biāo)"
      @close="hideData()"
    >
      <!--負(fù)載情況-->
      <div
        ref="bar_dv"
        :style="{
          width: '100%',
          minHeight: '300px',
        }"
      ></div>
    </div>
  </div>
</template>
 
<script>
import echarts from 'echarts'
// import myIcon from './image/hot_icon.png' //自定義圖標(biāo)
// import averageIcon from './image/hot_icon.png'
export default {
  name: "Echarts",
  data () {
    return {
      maxStr: 400,
      yInterval: 80,
      myData: [122, 45, 67, 78, 46],
      averageData: [32, 34, 6, 73, 84, 40]
    }
  },
  //外部傳入數(shù)據(jù)的話要監(jiān)聽數(shù)據(jù)start
  // props: {
  //   myData: {
  //     type: Array,
  //     default: []
  //   },
  //   averageData: {
  //     type: Array,
  //     default: []
  //   }
  // },
  // computed: {
  //   address () {
  //     const { myData, averageData } = this
  //     return {
  //       myData,
  //       averageData
  //     }
  //   }
  // },
  // watch: {
  //   address: {
  //     handler: function (val) {
  //       this.compare(val.myData, val.averageData)
  //       let newArr = val.myData.concat(val.averageData)
  //       let maxNum = Math.max(...newArr)
  //       this.maxStr = maxNum
  //       if (maxNum >= 500) {
  //         this.yInterval = 200
  //       } else {
  //         this.yInterval = 50
  //       }
  //       this.drawLine(val.myData, val.averageData)
  //     },
  //     deep: true

  //   }
  // },
  // mounted () {
  // this.$nextTick(function () {
  //   this.drawLine();
  // });
  // },
  //外部傳入數(shù)據(jù)的話要監(jiān)聽數(shù)據(jù)end

  mounted () {
    this.drawLine(this.myData, this.averageData)
  },
  methods: {
    //判斷一一對應(yīng)數(shù)據(jù)低于平均就提示
    compare (arr1, arr2) {
      if (arr1[0] < arr2[0]) {
        this.isCompare = true
      } else if (arr1[1] < arr2[1]) {
        this.isCompare = true
      } else if (arr1[2] < arr2[2]) {
        this.isCompare = true
      } else if (arr1[3] < arr2[3]) {
        this.isCompare = true
      } else {
        this.isCompare = false
      }
    },
    clickClose () {
      this.isCompare = false
    },
    /*負(fù)載情況圖標(biāo)*/
    drawLine (a, b) {
      var myData = a;
      var averageData = b;
      let bar_dv = this.$refs.bar_dv;
      let myChart = echarts.init(bar_dv);
      var autoHeight = parseInt(this.maxStr / 100) * 10 + 100;
      myChart.getDom().style.height = autoHeight + "px";
      myChart.resize(); //自適應(yīng)高度

      // 繪制圖表
      myChart.setOption({
        title: { text: '報表展示' },
        grid: {
          // left: 40,
          containLable: true
        },
        tooltip: {},
        xAxis: {
          data: ["看過我的", "溝通過的", "收到簡歷", "曝光人數(shù)"],
          axisLine: {
            lineStyle: {
              type: 'solid',
              color: '#eeeeee', //x左邊線的顏色
              fontSize: 13,
              width: '0.5' //坐標(biāo)線的寬度
            }
          },
          axisLabel: { //x軸字體
            textStyle: {
              color: '#333333',
              fontSize: 13
            }
          },
        },
        yAxis: {
          type: 'value',
          min: 0,
          max: this.maxStr,
          interval: this.yInterval,
          axisLine: {
            lineStyle: {
              type: 'solid',
              color: '#fff', //左邊線的顏色
              width: '0.5' //坐標(biāo)線的寬度
            }
          },
          axisLabel: {
            textStyle: {
              color: '#333333',
              fontSize: 13
            }
          },
          splitLine: {
            show: true,
            lineStyle: {
              color: ['#eeeeee'],
              width: 1,
              type: 'solid'
            }
          }

        },
        legend: {
          itemWidth: 11,
          itemHeight: 12,
          symbolKeepAspect: true,
          textStyle: {
            fontSize: 11,
            lineHeight: 0,
            backgroundColor: "rgba(11, 164, 19, 1)"
          },
          // icon: `image://${averageIcon}`,

          data: [
            {
              name: '我的',
              // icon: `image://${myIcon}`//自定義小圖標(biāo)
            },
            {
              name: '行業(yè)平均',
              // icon: `image://${averageIcon}`
            }
          ],
          align: 'left',
          right: 40,
          top: '0',
          textStyle: {
            fontSize: 12,
            textAlign: 'center',
            color: '#333333',
            magrinRight: 3
          },
        },
        series: [{
          name: '我的',
          type: 'bar',
          data: myData,
          barWidth: 16, //柱子寬度
          barGap: '50%',//間距
          label: {
            show: true,
            position: 'top',
            textStyle: {
              color: '#4695F3'
            },
            formatter: function (params) {
              return params.value
            }
          },
          itemStyle: {
            normal: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                offset: 0,
                color: '#A5CCF6'
              }, {
                offset: 1,
                color: '#4695F3'
              }]),
              barBorderRadius: [4, 4, 0, 0],
            }
          }
        },
        {
          name: '行業(yè)平均',
          type: 'bar',
          data: averageData,
          barWidth: 16,
          barGap: '50%',
          label: {
            show: true,
            position: 'top',
            textStyle: {
              color: '#FE8401'
            },
            formatter: function (params) {
              return params.value
            }
          },
          itemStyle: {
            normal: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                offset: 0,
                color: '#FFB235'
              }, {
                offset: 1,
                color: '#FE8401'
              }]),
              barBorderRadius: [4, 4, 0, 0],
            },
            emphasis: {
              barBorderRadius: 30
            },
          }
        }
        ]
      }, true);
    },

    hideData () {
      this.$emit("hideDialog")
    },

    confirm () {
      this.hideData();
    },

  }
}
</script>
 
<style scoped>
.echarts_con {
  width: 100%;
  margin: 0 auto;
  margin-top: 8px;
  border-radius: 20px;
  background: #fff;
  padding-bottom: 35px;
}
.echarts_main {
  width: 100%;
  margin: 0 auto;
  padding-top: 20px;
  margin-bottom: -32px;
  margin-right: 20px;
  margin-left: 20px;
}
.bottom {
  width: 90%;
  margin: 0 auto;
  background: #fef8e1;
  border-radius: 6px;
  height: 100%;
  margin-top: 16px;
}
.bottom_con {
  width: 90%;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 34px;
  line-height: 34px;
}
.bottom_text {
  height: 34px;
  line-height: 34px;
  font-size: 13px;
  font-family: PingFang, PingFang-SC;
  font-weight: SC;
  text-align: left;
  color: #fa5d1d;
}
.right_close {
  width: 13px;
  height: 13px;
}
</style>

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue內(nèi)置指令詳解

    vue內(nèi)置指令詳解

    指令是Vue模板中最常用的一項功能,它帶有前綴v-,主要職責(zé)是當(dāng)其表達(dá)式的值改變時,相應(yīng)的將某些行為應(yīng)用在 DOM 上。這篇文章主要介紹了vue內(nèi)置指令詳解,需要的朋友可以參考下
    2018-04-04
  • vue3+elementPlus項目支持生成、設(shè)置默認(rèn)附件方式

    vue3+elementPlus項目支持生成、設(shè)置默認(rèn)附件方式

    這篇文章主要介紹了vue3+elementPlus項目支持生成、設(shè)置默認(rèn)附件方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-03-03
  • petite vue 基本使用指南示例小結(jié)

    petite vue 基本使用指南示例小結(jié)

    petite-vue 是為漸進(jìn)增強而優(yōu)化的另一種 Vue 發(fā)行版,它提供與標(biāo)準(zhǔn) Vue 相同的模板語法和反應(yīng)性心智模型,這篇文章主要介紹了petite vue 基本使用指南,需要的朋友可以參考下
    2024-07-07
  • 關(guān)于Vue 自定義指令實現(xiàn)元素拖動的詳細(xì)代碼

    關(guān)于Vue 自定義指令實現(xiàn)元素拖動的詳細(xì)代碼

    這篇文章主要介紹了Vue 自定義指令實現(xiàn)元素拖動,在使用自定義指令之前,先對自定義指令有一定的了解,主要從自定義指令定義范圍,鉤子函數(shù)方面入手,需要的朋友可以參考下
    2022-01-01
  • 源碼分析Vue3響應(yīng)式核心之effect

    源碼分析Vue3響應(yīng)式核心之effect

    這篇文章主要為大家詳細(xì)介紹了Vue3響應(yīng)式核心之effect的相關(guān)知識,文中的示例代碼講解詳細(xì),對我們學(xué)習(xí)Vue3有一定的幫助,需要的可以參考一下
    2023-04-04
  • vue 動態(tài)設(shè)置瀏覽器標(biāo)題的方法詳解

    vue 動態(tài)設(shè)置瀏覽器標(biāo)題的方法詳解

    這篇文章主要為大家介紹了vue動態(tài)設(shè)置瀏覽器標(biāo)題的方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助
    2021-12-12
  • vue3與elementui封裝一個便捷Loading

    vue3與elementui封裝一個便捷Loading

    這篇文章主要介紹了vue3與elementui封裝一個便捷Loading,,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價值,需要的小伙伴可以參考一下
    2022-09-09
  • vue-cli構(gòu)建項目下使用微信分享功能

    vue-cli構(gòu)建項目下使用微信分享功能

    這篇文章主要介紹了vue-cli構(gòu)建項目下使用微信分享功能,本文通過實例代碼相結(jié)合的形式給大家介紹的非常詳細(xì),感興趣的朋友跟隨腳本之家小編一起學(xué)習(xí)吧
    2018-05-05
  • 如何在vue中使用pdfjs預(yù)覽pdf文件

    如何在vue中使用pdfjs預(yù)覽pdf文件

    本文主要講解了如何在vue中使用pdfjs預(yù)覽pdf文件,這樣的優(yōu)勢是無須讓用戶安裝專門的軟件即可實現(xiàn)預(yù)覽,下面就看看如何實現(xiàn)這個需求
    2021-06-06
  • el-tree設(shè)置選中高亮/焦點高亮、選中節(jié)點加深背景及更改字體顏色等的方法

    el-tree設(shè)置選中高亮/焦點高亮、選中節(jié)點加深背景及更改字體顏色等的方法

    el-tree默認(rèn)有較淺的背景色,這里業(yè)務(wù)需要,選中節(jié)點的字體高亮,更改顏色,下面這篇文章主要給大家介紹了關(guān)于el-tree選中高亮/焦點高亮、選中節(jié)點加深背景及更改字體顏色等的設(shè)置方法,需要的朋友可以參考下
    2022-12-12

最新評論