elementUI 使用echarts插件


1.npm安裝echarts:

npm install echarts -s

2.全局引入(我們安裝完成之后,可以在main.js中全局引入echarts)

import echarts from "echarts";

Vue.prototye.$echarts = echarts;

3.html代碼:

<template>
    <div id="chartColumn" style="width: 100%; height: 400px;">
    </div>
</template>

4.js代碼:

<script>
        import echarts from 'echarts'
        export default {
            data(){
                return {
                    chartColumn: null
                }
            },
            mounted() {
                this.drawLine();
            },
            methods: {
                drawLine(){
                    this.chartColumn = echarts.init(document.getElementById('chartColumn'));

                    this.chartColumn.setOption({
                      title: { text: 'Column Chart' },
                      tooltip: { trigger: "axis", axisPointer: { type: "cross", label: { backgroundColor: "#76baf1" } } },
                      xAxis: {
                        type: 'category',
                        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
                      },
                      yAxis: {
                        type: 'value'
                      },
                      series: [{
                        data: [820, 932, 901, 934, 1290, 1330, 1320],
                        type: 'line'
                      }]
                });
                }
            }
        }
    </script>

5.類型type:

type: 'bar':柱狀/條形圖
type: 'line':折線/面積圖
type: 'pie':餅圖
type: 'scatter':散點(氣泡)圖
type: 'effectScatter':帶有漣漪特效動畫的散點(氣泡)
type: 'radar':雷達圖
type: 'tree':樹型圖
type: 'treemap':樹型圖
type: 'sunburst':旭日圖
type: 'boxplot':箱形圖
type: 'candlestick':K線圖
type: 'heatmap':熱力圖
type: 'map':地圖
type: 'parallel':平行坐標系的系列
type: 'lines':線圖
type: 'graph':關系圖
type: 'sankey':桑基圖
type: 'funnel':漏斗圖
type: 'gauge':儀表盤
type: 'pictorialBar':象形柱圖
type: 'themeRiver':主題河流
type: 'custom':自定義系列

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM