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

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

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

本文實(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 = ['自動(dòng)接警', '人工接警']
      this.xAxisData = ['2018-09-02', '2019-02-25', '2019-05-25']
      this.seriesData = [
        {
          name: '自動(dòng)接警',
          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>

效果圖

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

相關(guān)文章

  • vue如何實(shí)現(xiàn)動(dòng)態(tài)的選中狀態(tài)切換效果

    vue如何實(shí)現(xiàn)動(dòng)態(tài)的選中狀態(tài)切換效果

    這篇文章主要介紹了vue如何實(shí)現(xiàn)動(dòng)態(tài)的選中狀態(tài)切換效果,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-04-04
  • 詳解VUE中常用的幾種import(模塊、文件)引入方式

    詳解VUE中常用的幾種import(模塊、文件)引入方式

    這篇文章主要介紹了詳解VUE中常用的幾種import(模塊、文件)引入方式,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-07-07
  • ajax請(qǐng)求+vue.js渲染+頁(yè)面加載的示例

    ajax請(qǐng)求+vue.js渲染+頁(yè)面加載的示例

    下面小編就為大家分享一篇ajax請(qǐng)求+vue.js渲染+頁(yè)面加載的示例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-02-02
  • Vant?UI中van-collapse下拉折疊面板默認(rèn)展開(kāi)第一項(xiàng)的方法

    Vant?UI中van-collapse下拉折疊面板默認(rèn)展開(kāi)第一項(xiàng)的方法

    之前做項(xiàng)目的時(shí)候,使用了Collapse折疊面板,下面這篇文章主要給大家介紹了關(guān)于Vant?UI中van-collapse下拉折疊面板默認(rèn)展開(kāi)第一項(xiàng)的相關(guān)資料,需要的朋友可以參考下
    2022-03-03
  • elementUi vue el-radio 監(jiān)聽(tīng)選中變化的實(shí)例代碼

    elementUi vue el-radio 監(jiān)聽(tīng)選中變化的實(shí)例代碼

    這篇文章主要介紹了elementUi vue el-radio 監(jiān)聽(tīng)選中變化,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-06-06
  • vue實(shí)現(xiàn)從外部修改組件內(nèi)部的變量的值

    vue實(shí)現(xiàn)從外部修改組件內(nèi)部的變量的值

    這篇文章主要介紹了vue實(shí)現(xiàn)從外部修改組件內(nèi)部的變量的值,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-07-07
  • Vue實(shí)現(xiàn)自定義右擊刪除菜單的示例

    Vue實(shí)現(xiàn)自定義右擊刪除菜單的示例

    本文主要介紹了Vue實(shí)現(xiàn)自定義右擊刪除菜單的示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2023-02-02
  • vue proxyTable的跨域中pathRewrite配置方式

    vue proxyTable的跨域中pathRewrite配置方式

    這篇文章主要介紹了vue proxyTable的跨域中pathRewrite配置方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-04-04
  • 一文詳解Vue中的虛擬DOM與Diff算法

    一文詳解Vue中的虛擬DOM與Diff算法

    vue中的diff算法時(shí)常是面試過(guò)程中的考點(diǎn),本文將為大家講解何為diff以及diff算法的實(shí)現(xiàn)過(guò)程,那么在了解diff之前,我們需要先了解虛擬DOM是什么,需要的朋友可以參考下
    2024-02-02
  • Pinia入門學(xué)習(xí)之實(shí)現(xiàn)簡(jiǎn)單的用戶狀態(tài)管理

    Pinia入門學(xué)習(xí)之實(shí)現(xiàn)簡(jiǎn)單的用戶狀態(tài)管理

    Vue3雖然相對(duì)于Vue2很多東西都變了,但是核心的東西還是沒(méi)有變,比如說(shuō)狀態(tài)管理、路由等,再Vue3中尤大神推薦我們使用pinia來(lái)實(shí)現(xiàn)狀態(tài)管理,他也說(shuō)pinia就是Vuex的新版本,這篇文章主要給大家介紹了關(guān)于Pinia入門學(xué)習(xí)之實(shí)現(xiàn)簡(jiǎn)單的用戶狀態(tài)管理的相關(guān)資料,需要的朋友可以參考下
    2022-11-11

最新評(píng)論