Bilicom.vue 3.7 KB
Newer Older
yma16's avatar
yma16 已提交
1 2 3 4 5 6 7 8

<template>
  <div class="echarts" style="text-align: left">
    <div id="bilicom" style="with: 100%; height: 100%">echart_test</div>
  </div>
</template>

<script>
yma16's avatar
yma16 已提交
9 10 11
// import * as echarts from 'echarts'


yma16's avatar
yma16 已提交
12
export default {
yma16's avatar
yma16 已提交
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
    name: 'Bilicom',
    data () {
        return {
            msg: '内容',
            md_data: [],
            data: ['threejs加载模型']
        }
    },
    methods: {
        echartfunc: function () {
            if (!echarts) return
            // 基于准备好的dom,初始化echarts实例
            const myChart = echarts.init(document.getElementById('bilicom'))
            const option = {
                backgroundColor: 'rgba(0, 0, 0, 0.3)',
yma16's avatar
yma16 已提交
28

yma16's avatar
yma16 已提交
29 30 31 32 33 34 35 36
                title: {
                    text: 'echarts',
                    left: 'center',
                    top: 20,
                    textStyle: {
                        color: '#ccc'
                    }
                },
yma16's avatar
yma16 已提交
37

yma16's avatar
yma16 已提交
38 39 40
                tooltip: {
                    trigger: 'item'
                },
yma16's avatar
yma16 已提交
41

yma16's avatar
yma16 已提交
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
                visualMap: {
                    show: false,
                    min: 80,
                    max: 600,
                    inRange: {
                        colorLightness: [0, 1]
                    }
                },
                series: [
                    {
                        name: '学习动力',
                        type: 'pie',
                        radius: '55%',
                        center: ['50%', '50%'],
                        data: [
                            { value: 335, name: '反向素材' },
                            { value: 310, name: '励志故事' },
                            { value: 274, name: '心灵鸡汤' },
                            { value: 235, name: '社会压力' },
                            { value: 400, name: '发自内心' }
                        ].sort(function (a, b) {
                            return a.value - b.value
                        }),
                        roseType: 'radius',
                        label: {
                            color: 'rgba(255, 255, 255, 0.3)'
                        },
                        labelLine: {
                            lineStyle: {
                                color: 'rgba(255, 255, 255, 0.3)'
                            },
                            smooth: 0.2,
                            length: 10,
                            length2: 20
                        },
                        itemStyle: {
                            color: '#c23531',
                            shadowBlur: 200,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        },
yma16's avatar
yma16 已提交
82

yma16's avatar
yma16 已提交
83 84 85 86 87 88 89
                        animationType: 'scale',
                        animationEasing: 'elasticOut',
                        animationDelay: function (idx) {
                            return Math.random() * 200
                        }
                    }
                ]
yma16's avatar
yma16 已提交
90
            }
yma16's avatar
yma16 已提交
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
            myChart.setOption(option)
        }
    },
    created: function () {
        const that = this
        try {
            that.echartfunc()
            window.onload = that.echartfunc
        } catch (e) {
            console.log(e)
        } finally {
            that.echartfunc()
        }
    },
    mounted () {
        let that = this
        try {
            that.echartfunc()
            window.onload = that.echartfunc
        } catch (e) {
            console.log(e)
        } finally {
            that.echartfunc()
        }
yma16's avatar
yma16 已提交
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
    }
}
</script>

<style scoped>
.echarts {
  margin: 0;
  width: 100%;
  height: 100%;
}

#bilicom {
  /* align-content: left; */
  width: 100%;
  height: 100%;
  background: url(/image/snow/previewFix.jpg) center top no-repeat;
  /* opacity: 1; */
}
</style>