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

vue+echarts實(shí)現(xiàn)堆疊柱狀圖

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

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

echarts-子組件

<template>
  <div class="chart" ref="chartEle"></div>
</template>
<script>
  import echarts from "echarts";
  import eventBus from '@/components/event/event-bus'
  export default {
    props: {
      legendData: {
        type: Array,
        default: []
      },
      xAxisData: {
        type: Array,
        default: []
      },
      seriesData: {
        type: Array,
        default: []
      }

    },

    data() {
      return {
        echartsObj: null,
      }
    },

    mounted() {
      var that = this
      eventBus.$on("window-resize", target => {
        that.echartsObj && that.echartsObj.resize()
      });
    },

    methods: {
      initCharts() {
        this.echartsObj = echarts.init(this.$refs.chartEle)
        this.setOption()
        // window.onresize = function() {
        //   this.echartsObj.resize()
        // }
      },

      resizeChart() {
        this.echartsObj.resize()
      },

      setOption() {
        const that = this
        var option = {
          color: ['#2DC6C8', '#B6A2DD'],
          // tooltip: { trigger: 'item', formatter: "{a} : {c}" },
          tooltip: {  },
          //右側(cè)數(shù)據(jù)視圖、折線圖、還原、保存顯示標(biāo)志
          toolbox: {
            feature: {
              // dataView: {show: true, readOnly: false},
              // magicType: {show: true, type: ['line', 'bar']},
              // restore: {show: true},
              // saveAsImage: {show: true}
              magicType: {
                show: true,
                type: ["line", "bar"],
                icon: {
                  line: "image:///static/images/toolbox_zhexian.png",
                  bar: "image:///static/images/toolbox_zhuzhuangtu.png"
                }
              },
              restore: {
                show: true,
                icon: "image:///static/images/toolbox_shuaxin.png"
              },
              saveAsImage: {
                show: true,
                icon: "image:///static/images/toolbox_xiazai.png"
              }
            }
          },
          legend: {
            bottom: '5',
            data: this.legendData
          },
          grid: {
            top: '40'
          },
          xAxis: [
            {
              type: 'category',
              data: this.xAxisData,
              axisLine: { lineStyle: { color: '#7DABB0' }} // x軸刻度線顏色
            }
          ],
          yAxis: [
            {
              type: 'value',
              axisLine: {
                lineStyle: { color: '#7DABB0' } // y軸坐標(biāo)軸顏色
              },
              axisTick: {
                lineStyle: { color: '#7DABB0' } // y軸坐標(biāo)刻度顏色
              }
            }
          ],
          series: this.seriesData
        }
        this.echartsObj.setOption(option)
      }
    }
  }
</script>
<style scoped>
  .chart {
    height: 360px;
    width: 100%;
  }
</style>

echarts父組件

<template>
  <div>
    <form-search @onSearch="onSearch"> </form-search>
    <div class="panel orioc-table-panel" slot="center">
      <!-- 圖表 -->
      <diversification-BarChart
        ref="barCharts"
        :legendData="legendData"
        :seriesData="seriesData"
        :xAxisData="xAxisData"
      ></diversification-BarChart>
      <!-- 表格 -->

    </div>


  </div>
</template>

<script>
  import FormSearch from '@/components/formSearch/formSearch'
  import eventBus from '@/components/event/event-bus'
  import DiversificationBarChart from '@/components/echarts/diversificationBarChart/index'
  export default {
    name: 'list',
    // 組件
    components: { FormSearch, eventBus, DiversificationBarChart },
    data() {
      return {
        legendData: [], // 圖例
        xAxisData: [], // x軸
        seriesData: []// 圖數(shù)據(jù)
      }
    },
    mounted() {
      // 加載列表
      this.legendData = ['自動接警', '人工接警']
      this.xAxisData = ['2018-09-02', '2019-02-25', '2019-05-25']
      this.seriesData = [
        {
          name: '自動接警',
          type: 'bar',
          stack:'111',//堆疊
          barMaxWidth: '100',//柱狀圖最大寬度
          data: [20, 30, 40]
        },
        {
          name: '人工接警',
          type: 'bar',
          stack:'111',//堆疊
          barMaxWidth: '100',//柱狀圖最大寬度
          data: [10, 50, 35]
        }
      ]
      this.$nextTick(() => {
        eventBus.$emit('window-resize')
        this.$refs.barCharts.initCharts()
      })
    },
    methods: {
      onSearch(data) {}
    }
  }
</script>

<style scoped>

</style>

效果圖

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

相關(guān)文章

  • Vue彈出菜單功能的實(shí)現(xiàn)代碼

    Vue彈出菜單功能的實(shí)現(xiàn)代碼

    這篇文章主要介紹了Vue左側(cè)底部彈出菜單功能的實(shí)現(xiàn)代碼,需要的朋友可以參考下
    2018-09-09
  • Vue中的偵聽器及使用場景

    Vue中的偵聽器及使用場景

    Vue中的偵聽器是一種響應(yīng)式機(jī)制,可以對指定的數(shù)據(jù)進(jìn)行監(jiān)聽,并在數(shù)據(jù)變化時執(zhí)行相應(yīng)的回調(diào)函數(shù)。常用于監(jiān)聽復(fù)雜數(shù)據(jù)類型的變化,如對象和數(shù)組。通過偵聽器,可以實(shí)現(xiàn)數(shù)據(jù)的自動更新和邏輯處理等功能,提高代碼的可讀性和可維護(hù)性
    2023-05-05
  • VUE Error: getaddrinfo ENOTFOUND localhost

    VUE Error: getaddrinfo ENOTFOUND localhost

    這篇文章主要介紹了VUE Error: getaddrinfo ENOTFOUND localhost,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-05-05
  • Vue實(shí)現(xiàn)todo應(yīng)用的示例

    Vue實(shí)現(xiàn)todo應(yīng)用的示例

    這篇文章主要介紹了Vue實(shí)現(xiàn)todo應(yīng)用的示例,幫助大家更好的理解和學(xué)習(xí)使用vue框架,感興趣的朋友可以了解下
    2021-02-02
  • Vue使用NProgress實(shí)現(xiàn)頁面頂部的進(jìn)度條顯示效果

    Vue使用NProgress實(shí)現(xiàn)頁面頂部的進(jìn)度條顯示效果

    這篇文章主要介紹了vue Nprogress頁面頂部進(jìn)度條功能實(shí)現(xiàn),NProgress是頁面跳轉(zhuǎn)是出現(xiàn)在瀏覽器頂部的進(jìn)度條,本文通過實(shí)例代碼給大家講解,需要的朋友可以參考下
    2022-12-12
  • vue微信分享 vue實(shí)現(xiàn)當(dāng)前頁面分享其他頁面

    vue微信分享 vue實(shí)現(xiàn)當(dāng)前頁面分享其他頁面

    這篇文章主要為大家詳細(xì)介紹了vue微信分享功能,vue實(shí)現(xiàn)當(dāng)前頁面分享其他頁面,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-12-12
  • axios進(jìn)階實(shí)踐之利用最優(yōu)雅的方式寫ajax請求

    axios進(jìn)階實(shí)踐之利用最優(yōu)雅的方式寫ajax請求

    之前給大家介紹了jQuery利用最優(yōu)雅的方式寫ajax請求的相關(guān)內(nèi)容,這篇文章主要給大家介紹了關(guān)于axios進(jìn)階實(shí)踐之利用最優(yōu)雅的方式寫ajax請求的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起看看吧。
    2017-12-12
  • vue3+elementplus前端生成圖片驗(yàn)證碼完整代碼舉例

    vue3+elementplus前端生成圖片驗(yàn)證碼完整代碼舉例

    在開發(fā)過程中有時候需要使用圖片驗(yàn)證碼進(jìn)行增加安全強(qiáng)度,在點(diǎn)擊圖片時更新新的圖片驗(yàn)證碼,記錄此功能,以便后期使用,這篇文章主要給大家介紹了關(guān)于vue3+elementplus前端生成圖片驗(yàn)證碼的相關(guān)資料,需要的朋友可以參考下
    2024-03-03
  • vue移動端彈起蒙層滑動禁止底部滑動操作

    vue移動端彈起蒙層滑動禁止底部滑動操作

    這篇文章主要介紹了vue移動端彈起蒙層滑動禁止底部滑動操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-07-07
  • 詳解VUE中的Proxy代理

    詳解VUE中的Proxy代理

    這篇文章主要介紹了Proxy代理對象詳解,Proxy 是ES6中提供的一個非常強(qiáng)大的功能,可以用來代理另一個對象,從而攔截、監(jiān)視并修改這個對象的各種操作,需要的朋友可以參考下
    2023-04-04

最新評論