Price.vue 1.82 KB

<template>
  <div class="user-box">
    <div class="title-icon">
      <span class="title-bg">车价占比</span>
    </div>
    <div class="user-container flex">
      <pie-chart @pieAction="pieAction" ref="pieChart" :formatter="chart.formatter" :colors="chart.colors" :size="chart.size" :id="chart.id" :list="priceData" :keys="chart.keys" :radius="chart.radius" height="6.1vh"></pie-chart>
      <div class="legend-item flex">
        <span :style="{ background: descColor }"></span>
        {{ selectData && selectData.name }}
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Price',
  data() {
    return {
      selectData: '',
      descColor: '',
      chart: {
        id: 'user-price',
        keys: ['name', 'num'],
        radius: ['56%', '85%'],
        colors: ['#FF6E76', '#16E193', '#FDF006', '#EB6001', '#34AFFF', '#BF98FF', '#726BFF'],
        size: '8px',
        formatter: 'rate'
      },
      priceData: []
    }
  },
  created() {
    this.$bus.$on('userData', data => {
      this.priceData = data.priceData
    })
  },
  methods: {
    pieAction(data) {
      this.descColor = this.$refs.pieChart.descColor
      this.selectData = data
    }
  }
}
</script>
<style lang="scss" scoped>
.user-box {
  .title-icon {
    font-weight: 500;
    font-size: 10px;
    color: #ffffff;
    .title-bg {
      background-image: linear-gradient(90deg, #003f57 0%, #111056 54%, #071735 100%);
      padding-left: 0.83vw;
    }
  }
  .legend-item {
    width: 4.65vw;
    height: 1.83vh;
    background: #0A214D;
    font-weight: 400;
    font-size: 9px;
    color: #fff;
    margin-right: 2vw;
    span {
      width: 5px;
      height: 5px;
      border-radius: 50%;
      margin: 4px;
      display: inline-block;
    }
  }
}
</style>