1: Install line charts in the project

cnpm install echarts --s
Copy the code

2: Introduce charts where they are needed

import echarts from 'echarts'
Copy the code

3: Write a VUE code

<template>
    <section class="chart-container">
        <el-row>                     
            <el-col :span="12">
                <div id="chartPie" style="width:100%; height:400px;"></div>
            </el-col>          
        </el-row>
    </section>
</template>
<script>
    import echarts from 'echarts'

    export default {
        data() {
            return {                                     
                chartPie: null}},methods: {                               
            drawPieChart() {
                this.chartPie = echarts.init(document.getElementById('chartPie'));
                this.chartPie.setOption({
                    title: {
                        text: 'Pie Chart'.subtext: 'Pure fiction'.x: 'center'
                    },
                    tooltip: {
                        trigger: 'item'.formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },
                    legend: {
                        orient: 'vertical'.left: 'left'.data: ['Direct access'.'Email marketing'.'Affiliate advertising'.'Video advertising'.'Search engines']},series: [{name: 'Access source'.type: 'pie'.radius: '55%'.center: ['50%'.'60%'].data: [{value: 335.name: 'Direct access' },
                                { value: 310.name: 'Email marketing' },
                                { value: 234.name: 'Affiliate advertising' },
                                { value: 135.name: 'Video advertising' },
                                { value: 1548.name: 'Search engines'}].itemStyle: {
                                emphasis: {
                                    shadowBlur: 10.shadowOffsetX: 0.shadowColor: 'rgba (0, 0, 0, 0.5)'}}}]}); },drawCharts() {
                this.drawPieChart()
            },
        },

        mounted: function () {
            this.drawCharts()
        },
        // updated: function () {
        // this.drawCharts()
        // }
    }
</script>

<style scoped>
    .chart-container {
        width: 100%;
        float: left;
    }
    .el-col {
        padding: 30px 20px;
    }
</style>
Copy the code

4: The effect is as follows