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

Vue?Echarts實現(xiàn)多功能圖表繪制的示例詳解

 更新時間:2023年02月20日 10:39:54   作者:dkjhl  
作為前端人員,日常圖表、報表、地圖的接觸可謂相當(dāng)頻繁,今天小編隆重退出前端框架之VUE結(jié)合百度echart實現(xiàn)中國地圖+各種圖表的展示與使用;作為“你值得擁有”專欄階段性末篇,值得一看

前言

作為前端人員,日常圖表、報表、地圖的接觸可謂相當(dāng)頻繁,今天小編隆重退出前端框架之VUE結(jié)合百度echart實現(xiàn)中國地圖+各種圖表的展示與使用;作為“你值得擁有”專欄階段性末篇,值得一看

主要實現(xiàn)功能

  • 中國地圖
  • 環(huán)形圖
  • 折線圖
  • 柱形圖
  • 復(fù)雜交互
  • 單選復(fù)選

環(huán)境搭建

初始化環(huán)境參考:利用vue-cli搭建vue項目框架

項目部署

build project:

npm install

npm run build

npm run dev

訪問地址:

http://localhost:8895/#/dashboard

項目結(jié)構(gòu)

項目代碼

dashboard.vue-主界面

import pie from 'com/pie/pie'
import line from 'com/line/line'
import multipleColumn from 'com/multipleColumn/multipleColumn'
import point from 'com/point/point'
 
export default {
  data() {
    return {
      items: []
    }
  },
  mounted() {
    this.init()
  },
  methods: {
    oresize() {
      this.$root.charts.forEach((myChart) => {
        myChart.resize()
      })
    },
    init() {
      this.items = document.querySelectorAll('.flex-container .item')
      for (let i = 0; i < this.items.length; i++) {
        this.items[i].dataset.order = i + 1;
      }
    },
    clickChart(clickIndex) {
      let activeItem = document.querySelector('.flex-container .active')
      let activeIndex = activeItem.dataset.order
      let clickItem = this.items[clickIndex - 1]
      if (activeIndex === clickIndex) {
        return
      }
      activeItem.classList.remove('active')
      clickItem.classList.add('active')
      this._setStyle(clickItem, activeItem)
    },
    _setStyle(el1, el2) {
      let transform1 = el1.style.transform
      let transform2 = el2.style.transform
      el1.style.transform = transform2
      el2.style.transform = transform1
    }
  },
  components: {
    multipleColumn,
    point,
    'v-line': line,
    pie: pie
  }
}

multipleColumn.vue-復(fù)合柱形圖

import filter from 'com/filter/filter'
import echarts from 'echarts'
import china from 'echarts/map/js/china'
import world from 'echarts/map/js/world'
import http from 'js/http'
 
 
export default {
    data() {
        return {
            mcChart: {},
            options2: {
                shortcuts: [
                {
                    text: '最近一周',
                    value () {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                        return [start, end];
                    },
                    onClick: (picker) => {
                    }
                },
                {
                    text: '最近一個月',
                    value () {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                        return [start, end];
                    },
                    onClick: (picker) => {
                    }
                },
                {
                    text: '最近三個月',
                    value () {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                        return [start, end];
                    },
                    onClick: (picker) => {
                    }
                }
                ]
            },
            value2: '',
            startTime: '',
            endTime: '',
        }
    },
    methods: {
        _mcCharts() {
            var dom = document.querySelector('.multipleColumn .main')
            this.mcChart = echarts.init(dom);
            var app = {}, option = null;
            app.title = '堆疊柱狀圖';
 
            option = {
                title: {
                    text: '全國主要城市空氣質(zhì)量',
                    left: 'left',
                    textStyle: {
                        color: '#fff',
                        fontWeight: 300,
                    }
                },
                tooltip : {
                    trigger: 'axis',
                    axisPointer : {            // 坐標(biāo)軸指示器,坐標(biāo)軸觸發(fā)有效
                        type : 'shadow'        // 默認為直線,可選為:'line' | 'shadow'
                    }
                },
                color: ['#AE5548', '#6D9EA8', '#9CC2B0', '#C98769', '#48cda6','#fd87ab','#11abff','#ffdf33','#968ade'],
                legend: {
                    data:['直接訪問','郵件營銷','聯(lián)盟廣告','視頻廣告','搜索引擎','百度','谷歌','必應(yīng)','其他'],
                    x: 'right',
                    textStyle: {
                        // legend字體顏色
                        color: '#fff'
                    }
                },
                grid: {
                    left: '5%',
                    right: '8%',
                    top: '16%',
                    bottom: '3%',
                    containLabel: true
                },
                xAxis : [
                    {
                        name: '時間',
                        type : 'category',
                        data : ['周一','周二','周三','周四','周五','周六','周日'],
                        axisLine:{
                            lineStyle:{
                                color: '#fff',
                                type:'solid'  //'dotted'虛線 'solid'實線
                            }                         
                        }
                    }
                ],
                yAxis : [
                    {
                        name: '數(shù)量',
                        type : 'value',
                        splitLine: {
                        lineStyle: {
                                color: ['rgba(230, 230, 230, 0.2)'],
                                type:'dotted'  //'dotted'虛線 'solid'實線
                            }
                        },
                        axisLine: {
                            lineStyle:{
                                color: '#fff',
                                type:'solid'  //'dotted'虛線 'solid'實線
                            }                         
                        }
                    }
                ],
                series : [
                    {
                        name:'直接訪問',
                        type:'bar',
                        data:[320, 332, 301, 334, 390, 330, 320]
                    },
                    {
                        name:'郵件營銷',
                        type:'bar',
                        stack: '廣告',
                        data:[120, 132, 101, 134, 90, 230, 210]
                    },
                    {
                        name:'聯(lián)盟廣告',
                        type:'bar',
                        stack: '廣告',
                        data:[220, 182, 191, 234, 290, 330, 310]
                    },
                    {
                        name:'視頻廣告',
                        type:'bar',
                        stack: '廣告',
                        data:[150, 232, 201, 154, 190, 330, 410]
                    },
                    {
                        name:'搜索引擎',
                        type:'bar',
                        data:[862, 1018, 964, 1026, 1679, 1600, 1570],
                        markLine : {
                            lineStyle: {
                                normal: {
                                    type: 'dashed'
                                }
                            },
                            data : [
                                [{type : 'min'}, {type : 'max'}]
                            ]
                        }
                    },
                    {
                        name:'百度',
                        type:'bar',
                        barWidth : 5,
                        stack: '搜索引擎',
                        data:[620, 732, 701, 734, 1090, 1130, 1120]
                    },
                    {
                        name:'谷歌',
                        type:'bar',
                        stack: '搜索引擎',
                        data:[120, 132, 101, 134, 290, 230, 220]
                    },
                    {
                        name:'必應(yīng)',
                        type:'bar',
                        stack: '搜索引擎',
                        data:[60, 72, 71, 74, 190, 130, 110]
                    },
                    {
                        name:'其他',
                        type:'bar',
                        stack: '搜索引擎',
                        data:[62, 82, 91, 84, 109, 110, 120]
                    }
                ]
            };
            if (option && typeof option === "object") {
                this.mcChart.setOption(option, true);
            };
            // 綁定點擊事件
            this.mcChart.on('click', function (params) {
                console.log(params)
            })
        },
        // 時間插件
        onChangeDate(date) { // daterange改變的時候觸發(fā)的事件 默認接收一個date對象
            this.startTime = date[0];
            this.endTime = date[1];
        },
        // 時間插件
        okChange() { // 點擊確定按鈕觸發(fā)的事件
            var params = {startTime: this.startTime, endTime: this.endTime}
            if( params.startTime === '' || params.endTime=== '') {
                this.$Message.info('請選擇日期范圍');
                return
            } else {
                this._showPoint(params)
            }
        },
        // 時間插件
        onClear() {
            console.log('今日實況')
        },
    },
    mounted: function() {
        this._mcCharts()
        window.addEventListener('resize', function() { // 第一步:main中添加style="100%",第二步:添加.bind(this)
            this.mcChart.resize()
        }.bind(this));
    },
    components: {
        'v-filter': filter
    }
  
}

項目截圖

地圖功能

餅圖功能+單選復(fù)選

復(fù)雜折線圖+單選復(fù)選

復(fù)雜柱狀圖+單選復(fù)選

百度地圖api實現(xiàn)跳點

大屏展示

以上就是Vue Echarts實現(xiàn)多功能圖表繪制的示例詳解的詳細內(nèi)容,更多關(guān)于Vue Echarts多功能圖表的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • Vue3中多個彈窗同時出現(xiàn)的解決思路

    Vue3中多個彈窗同時出現(xiàn)的解決思路

    這篇文章主要介紹了Vue3中多個彈窗同時出現(xiàn)的解決思路,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-02-02
  • vue動態(tài)禁用控件綁定disable的例子

    vue動態(tài)禁用控件綁定disable的例子

    今天小編就為大家分享一篇vue動態(tài)禁用控件綁定disable的例子,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-10-10
  • VantUI封裝自定義Tabbar路由跳轉(zhuǎn)的實現(xiàn)

    VantUI封裝自定義Tabbar路由跳轉(zhuǎn)的實現(xiàn)

    本文主要介紹了VantUI封裝自定義Tabbar路由跳轉(zhuǎn)的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-05-05
  • Vue3中watch無法監(jiān)聽的解決辦法

    Vue3中watch無法監(jiān)聽的解決辦法

    本文主要介紹了Vue3中watch無法監(jiān)聽的解決辦法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-05-05
  • Vue3中element-plus全局使用Icon圖標(biāo)的過程詳解

    Vue3中element-plus全局使用Icon圖標(biāo)的過程詳解

    我們在用vue開發(fā)網(wǎng)站的時候,往往圖標(biāo)是起著很重要的作,這篇文章主要給大家介紹了關(guān)于Vue3中element-plus全局使用Icon圖標(biāo)的相關(guān)資料,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下
    2022-01-01
  • vue頂部菜單欄實現(xiàn)小結(jié)

    vue頂部菜單欄實現(xiàn)小結(jié)

    這篇文章主要介紹了vue頂部菜單欄實現(xiàn)小結(jié),本文通過實例代碼給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-06-06
  • Vite打包分割代碼的詳細過程記錄

    Vite打包分割代碼的詳細過程記錄

    項目創(chuàng)建Vite是一個web開發(fā)構(gòu)建工具,由于其原生ES模塊導(dǎo)入方法,它允許快速提供代碼,下面這篇文章主要給大家介紹了關(guān)于Vite打包分割代碼的相關(guān)資料,需要的朋友可以參考下
    2022-09-09
  • 在vue項目中使用sass語法問題

    在vue項目中使用sass語法問題

    sass是一個最初由Hampton Catlin設(shè)計并由Natalie Weizenbaum開發(fā)的層疊樣式表語言。這篇文章主要介紹了在vue項目中使用sass語法,需要的朋友可以參考下
    2019-07-07
  • vue項目中使用高德地圖的超詳細步驟

    vue項目中使用高德地圖的超詳細步驟

    在vue項目中添加高德地圖,對開發(fā)地圖的開發(fā)人員有一定幫助,下面這篇文章主要給大家介紹了關(guān)于vue項目中使用高德地圖的超詳細步驟,文中通過圖文以及實例代碼介紹的非常詳細,需要的朋友可以參考下
    2023-03-03
  • vuex 如何動態(tài)引入 store modules

    vuex 如何動態(tài)引入 store modules

    這篇文章主要介紹了vuex 如何動態(tài)引入 store modules,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-03-03

最新評論