flow.vue 2.14 KB
<!--
 * @Description: 客流转化
 * @Author: huyue
 * @Date: 2022-06-23 15:05:21
 * @LastEditors: huyue
 * @LastEditTime: 2022-06-24 16:26:20
-->
<template>
  <div class="flow-box">
    <div class="title inline">客流转化</div>
    <div class="chart-box">
      <div id="flow" :style="{ height: height - 3.1 + 'vh' }"></div>
    </div>
  </div>
</template>

<script>
import * as echarts from 'echarts'
export default {
  name: 'Flow',
  props: ['height'],
  data() {
    return {}
  },
  mounted() {
    this.getChart()
  },
  methods: {
    getChart() {
      var chartDom = document.getElementById('flow')
      var myChart = echarts.init(chartDom)
      var option

      option = {
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b} : {c}%'
        },
        series: [
          {
            name: 'Funnel',
            type: 'funnel',
            left: 0,
            top: 8,
            bottom: 8,
            width: '100%',
            min: 0,
            max: 100,
            minSize: '30%',
            maxSize: '100%',
            sort: 'descending',
            gap: 2,
            label: {
              show: true,
              position: 'inside'
            },
            labelLine: {
              length: 10,
              lineStyle: {
                width: 1,
                type: 'solid'
              }
            },
            itemStyle: {
              borderColor: '#fff',
              borderWidth: 1
            },
            emphasis: {
              label: {
                fontSize: 20
              }
            },
            data: [
              { value: 60, name: 'Visit' },
              { value: 40, name: 'Inquiry' },
              { value: 20, name: 'Order' },
              { value: 80, name: 'Click' },
              { value: 100, name: 'Show' }
            ]
          }
        ]
      }

      option && myChart.setOption(option)
    }
  }
}
</script>

<style lang="scss" scoped>
.flow-box {
  padding: 0 8px 1vh;
  box-sizing: border-box;
}
.chart-box {
  width: 148px;
  height: 11.7vh;
  background-color: #262525;
  padding: 0 25px;
  // margin: 0 20px 1vh 8px;
  // box-sizing: border-box;
}
</style>