91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

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

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

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

兰西县| 多伦县| 阳城县| 高陵县| 海盐县| 阳西县| 应城市| 伊金霍洛旗| 霍山县| 昌宁县| 新野县| 涿鹿县| 什邡市| 镇安县| 辽中县| 岳阳县| 盐源县| 昌黎县| 榆树市| 巩义市| 古丈县| 海口市| 若羌县| 东乌珠穆沁旗| 青冈县| 新郑市| 雅安市| 玉林市| 海丰县| 宜春市| 新野县| 祥云县| 广饶县| 镇沅| 永靖县| 平利县| 友谊县| 临泽县| 罗山县| 阿勒泰市| 新安县|