Bilicom.vue 2.8 KB
Newer Older
yma16's avatar
yma16 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

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

<script>
import * as echarts from 'echarts'
export default {
  name: 'Bilicom',
  data () {
    return {
      msg: '内容',
      md_data: [],
Y
yma16 已提交
16
      data: ['threejs加载模型']
yma16's avatar
yma16 已提交
17 18 19
    }
  },
  methods: {
Y
yma16 已提交
20
    echartfunc: function () {
yma16's avatar
yma16 已提交
21
      // 基于准备好的dom,初始化echarts实例
Y
yma16 已提交
22 23
      const myChart = echarts.init(document.getElementById('bilicom'))
      const option = {
yma16's avatar
yma16 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
        backgroundColor: 'rgba(0, 0, 0, 0.3)',

        title: {
          text: 'echarts',
          left: 'center',
          top: 20,
          textStyle: {
            color: '#ccc'
          }
        },

        tooltip: {
          trigger: 'item'
        },

        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)'
            },

            animationType: 'scale',
            animationEasing: 'elasticOut',
            animationDelay: function (idx) {
              return Math.random() * 200
            }
          }
        ]
      }
      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()
    }
  }
}
</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>