亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

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

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

Vue中如何使用echarts可視化組件

發布時間:2021-07-28 11:24:53 來源:億速云 閱讀:164 作者:Leah 欄目:開發技術

這篇文章將為大家詳細講解有關Vue中如何使用echarts可視化組件,文章內容質量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關知識有一定的了解。

1.找到腳手架項目所在地址,執行cnpm install echarts,安裝echarts組件

Vue中如何使用echarts可視化組件

(E:\demo\vuepro)這是我的項目地址,vuepro為項目名

2.按需導入,以加快打開速度

//引入echarts組件
    import echarts from "echarts"
    // 引入基本模板
    let echart = require('echarts/lib/echarts')
    // 引入柱狀圖組件
    require('echarts/lib/chart/bar')
    // 引入提示框和title組件
    require('echarts/lib/component/tooltip')
    require('echarts/lib/component/title')

3.準備div標簽 容納報表圖形

div的 id用于綁定echarts插件

 <div id="chart" >
 </div>

4.script標簽的內容

//引入echarts組件
    import echarts from "echarts"
    // 引入基本模板
    let echart = require('echarts/lib/echarts')
    // 引入柱狀圖組件
    require('echarts/lib/chart/bar')
    // 引入提示框和title組件
    require('echarts/lib/component/tooltip')
    require('echarts/lib/component/title')
            export default{
                name: 'App',
                data(){
                  return{
                     chartColumn:null
                  }
                },
                methods:{
                  initData(){
                    let dt=document.querySelector("#boss")

                    this.chartColumn=echart.init(dt)
                    this.chartColumn.setOption(
                       //Examples中的模板
                    )

                  }
                },
                mounted(){
                    this.initData()
                }
             }

為了方便大家的使用,我在這里放一個在Vue中引入echarts可視化組件的完整模板,大家直接復制使用即可

<template>
    <div id="boss" >
        
    </div>
</template>

<script>
    //引入echarts組件
    import echarts from "echarts"
    // 引入基本模板
    let echart = require('echarts/lib/echarts')
    // 引入柱狀圖組件
    require('echarts/lib/chart/bar')
    // 引入提示框和title組件
    require('echarts/lib/component/tooltip')
    require('echarts/lib/component/title')
            export default{
                name: 'App',
                data(){
                  return{
                     chartColumn:null
                  }
                },
                methods:{
                  initData(){
                    let dt=document.querySelector("#boss")
            
                    this.chartColumn=echart.init(dt)
                    this.chartColumn.setOption(
                       //Examples中模板
                    )
            
                  }
                },
                mounted(){
                    this.initData()
                }
             }
</script>

<style>
</style>

案例:

<template>
    <div id="boss" >

    </div>
</template>

<script>
    import echarts from "echarts"
    // 引入基本模板
    let echart = require('echarts/lib/echarts')
    // 引入柱狀圖組件
    require('echarts/lib/chart/bar')
    // 引入提示框和title組件
    require('echarts/lib/component/tooltip')
    require('echarts/lib/component/title')
            export default{
                name: 'App',
                data(){
                  return{
                     chartColumn:null
                  }
                },
                methods:{
                  initData(){
                    let dt=document.querySelector("#boss")

                    this.chartColumn=echart.init(dt)
                    this.chartColumn.setOption(
                    //以下為echarts可視化組件
                      {
                          tooltip: {
                              trigger: 'axis',
                              axisPointer: {            // Use axis to trigger tooltip
                                  type: 'shadow'        // 'shadow' as default; can also be 'line' or 'shadow'
                              }
                          },
                          legend: {
                              data: ['Direct', 'Mail Ad', 'Affiliate Ad', 'Video Ad', 'Search Engine']
                          },
                          grid: {
                              left: '3%',
                              right: '4%',
                              bottom: '3%',
                              containLabel: true
                          },
                          xAxis: {
                              type: 'value'
                          },
                          yAxis: {
                              type: 'category',
                              data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
                          },
                          series: [
                              {
                                  name: 'Direct',
                                  type: 'bar',
                                  stack: 'total',
                                  label: {
                                      show: true
                                  },
                                  emphasis: {
                                      focus: 'series'
                                  },
                                  data: [320, 302, 301, 334, 390, 330, 320]
                              },
                              {
                                  name: 'Mail Ad',
                                  type: 'bar',
                                  stack: 'total',
                                  label: {
                                      show: true
                                  },
                                  emphasis: {
                                      focus: 'series'
                                  },
                                  data: [120, 132, 101, 134, 90, 230, 210]
                              },
                              {
                                  name: 'Affiliate Ad',
                                  type: 'bar',
                                  stack: 'total',
                                  label: {
                                      show: true
                                  },
                                  emphasis: {
                                      focus: 'series'
                                  },
                                  data: [220, 182, 191, 234, 290, 330, 310]
                              },
                              {
                                  name: 'Video Ad',
                                  type: 'bar',
                                  stack: 'total',
                                  label: {
                                      show: true
                                  },
                                  emphasis: {
                                      focus: 'series'
                                  },
                                  data: [150, 212, 201, 154, 190, 330, 410]
                              },
                              {
                                  name: 'Search Engine',
                                  type: 'bar',
                                  stack: 'total',
                                  label: {
                                      show: true
                                  },
                                  emphasis: {
                                      focus: 'series'
                                  },
                                  data: [820, 832, 901, 934, 1290, 1330, 1320]
                              }
                          ]
                      }
                      //組件到此結束
                    )

                  }
                },
                mounted(){
                    this.initData()
                }
             }
</script>

<style>
</style>

顯示效果:

Vue中如何使用echarts可視化組件

關于Vue中如何使用echarts可視化組件就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

向AI問一下細節

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

AI

绥棱县| 绍兴县| 汤原县| 德保县| 宁武县| 麻江县| 文登市| 阜城县| 梓潼县| 连南| 项城市| 宁安市| 尖扎县| 城口县| 洮南市| 库尔勒市| 尉氏县| 乐山市| 泰来县| 柘城县| 临桂县| 龙陵县| 黄龙县| 剑河县| 子长县| 凤凰县| 洛宁县| 太仓市| 临海市| 泰兴市| 丹阳市| 巴林左旗| 敖汉旗| 中卫市| 会宁县| 华阴市| 通江县| 濮阳市| 海城市| 贵州省| 鄂托克前旗|