最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue使用Echarts實(shí)現(xiàn)數(shù)據(jù)可視化的方法詳解

 更新時(shí)間:2022年03月22日 11:09:49   作者:CapPengCheng&  
這篇文章主要為大家詳細(xì)介紹了Vue使用Echarts實(shí)現(xiàn)數(shù)據(jù)可視化的方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來(lái)幫助

一,Echarts

一個(gè)基于 JavaScript 的開(kāi)源可視化圖表庫(kù)

Echarts官網(wǎng)

https://echarts.apache.org/zh/index.html

在這里插入圖片描述

1.1 獲取ECharts

(1)從 npm 獲?。?xiàng)目獲取)

npm install echarts --save

(2)從 CDN 獲取

推薦從 jsDelivr 引用 echarts。

(3)從 GitHub 獲取

apache/echarts 項(xiàng)目的 release 頁(yè)面可以找到各個(gè)版本的鏈接。點(diǎn)擊下載頁(yè)面下方 Assets 中的 Source code,解壓后 dist 目錄下的 echarts.js 即為包含完整 ECharts 功能的文件。

1.2 引入 ECharts

import * as echarts from 'echarts';

// 基于準(zhǔn)備好的dom,初始化echarts實(shí)例
var myChart = echarts.init(document.getElementById('main'));
// 繪制圖表
myChart.setOption({
  title: {
    text: 'ECharts 入門(mén)示例'
  },
  tooltip: {},
  xAxis: {
    data: ['襯衫', '羊毛衫', '雪紡衫', '褲子', '高跟鞋', '襪子']
  },
  yAxis: {},
  series: [
    {
      name: '銷(xiāo)量',
      type: 'bar',
      data: [5, 20, 36, 10, 10, 20]
    }
  ]
});

二,Vue使用Echarts

2.1 Vue環(huán)境

ES6、vue、vuex、vue-router、vue-cli、axios、element-ui
Node >= 10

2.2 main.js引入Echarts

// 引入Echarts
import echarts from 'echarts'
Vue.prototype.$echarts = echarts

2.3 使用模板

<template>
  <div id="myChart" :style="{width: '100%', height: '1000px'}" />
</template>
<script>
export default {
  mounted() {
    this.drawLine()
  },
  methods: {
    drawLine() {
      // 基于準(zhǔn)備好的dom,初始化echarts實(shí)例
      const myChart = this.$echarts.init(document.getElementById('myChart'))
      myChart.setOption({
       //官網(wǎng)實(shí)例代碼,如下圖
      })
    }
  }
}
</script>

在這里插入圖片描述

2.4實(shí)例

2.4.1柱狀圖(折線(xiàn)圖變換)

<template>
  <div id="myChart" :style="{width: '100%', height: '1000px'}" />
</template>
<script>

export default {
  mounted() {
    this.drawLine()
  },
  methods: {
    drawLine() {
      // 基于準(zhǔn)備好的dom,初始化echarts實(shí)例
      const myChart = this.$echarts.init(document.getElementById('myChart'))
      myChart.setOption({
        title: {
          text: 'Rainfall vs Evaporation',
          subtext: 'Fake Data'
        },
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: ['Rainfall', 'Evaporation']
        },
        toolbox: {
          show: true,
          feature: {
            dataView: { show: true, readOnly: false },
            magicType: { show: true, type: ['line', 'bar'] },
            restore: { show: true },
            saveAsImage: { show: true }
          }
        },
        calculable: true,
        xAxis: [
          {
            type: 'category',
            // prettier-ignore
            data: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
          }
        ],
        yAxis: [
          {
            type: 'value'
          }
        ],
        series: [
          {
            name: 'Rainfall',
            type: 'bar',
            data: [
              2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3
            ],
            markPoint: {
              data: [
                { type: 'max', name: 'Max' },
                { type: 'min', name: 'Min' }
              ]
            },
            markLine: {
              data: [{ type: 'average', name: 'Avg' }]
            }
          },
          {
            name: 'Evaporation',
            type: 'bar',
            data: [
              2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3
            ],
            markPoint: {
              data: [
                { name: 'Max', value: 182.2, xAxis: 7, yAxis: 183 },
                { name: 'Min', value: 2.3, xAxis: 11, yAxis: 3 }
              ]
            },
            markLine: {
              data: [{ type: 'average', name: 'Avg' }]
            }
          }
        ]
      })
    }
  }
}
</script>

在這里插入圖片描述

在這里插入圖片描述

在這里插入圖片描述

2.4.2極坐標(biāo)柱狀圖標(biāo)簽

<template>
  <div id="myChart" :style="{width: '100%', height: '1000px'}" />
</template>
<script>

export default {
  mounted() {
    this.drawLine()
  },
  methods: {
    drawLine() {
      // 基于準(zhǔn)備好的dom,初始化echarts實(shí)例
      const myChart = this.$echarts.init(document.getElementById('myChart'))
      myChart.setOption({
        title: [
          {
            text: 'Radial Polar Bar Label Position (middle)'
          }
        ],
        polar: {
          radius: [30, '80%']
        },
        radiusAxis: {
          max: 4
        },
        angleAxis: {
          type: 'category',
          data: ['a', 'b', 'c', 'd'],
          startAngle: 75
        },
        tooltip: {},
        series: {
          type: 'bar',
          data: [2, 1.2, 2.4, 3.6],
          coordinateSystem: 'polar',
          label: {
            show: true,
            position: 'middle',
            formatter: ': {c}'
          }
        },
        backgroundColor: '#fff',
        animation: false
      })
    }
  }
}
</script>

在這里插入圖片描述

總結(jié)

本篇文章就到這里了,希望能夠給你帶來(lái)幫助,也希望您能夠多多關(guān)注腳本之家的更多內(nèi)容!   

相關(guān)文章

最新評(píng)論

垣曲县| 深泽县| 石家庄市| 桓台县| 克山县| 阿合奇县| 汉寿县| 沛县| 洛扎县| 竹山县| 哈巴河县| 宿松县| 嵩明县| 沙河市| 郴州市| 子长县| 崇文区| 长沙市| 东乌| 五指山市| 万全县| 鄄城县| 松潘县| 南部县| 绥阳县| 海丰县| 德保县| 江达县| 紫云| 延庆县| 社会| 沙坪坝区| 合山市| 岳阳市| 宁津县| 南召县| 玉山县| 沙田区| 澳门| 库尔勒市| 南康市|