OperationaLegend.vue 1.54 KB
<!--
 * @Description: 
 * @Author: huyue
 * @Date: 2024-01-25 16:52:03
 * @LastEditors: huyue
 * @LastEditTime: 2024-07-12 16:21:17
-->
<template>
  <div class="legend">
    <div class="legend-item flex" :style="{width: width,height: height}" v-for="(item, index) in dataList" :key="index">
      <div class="icon" :style="{ background: colors[index] }"></div>
      <div class="item-content">{{ item.name }}</div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'OperationaLegend',
  data() {
    return {
      dataList: this.list
    }
  },
  props: {
    list: {
      type: Array,
      default: () => []
    },
    colors: {
      type: Array,
      default: () => ['#FF6E76', '#7CFFB2', ' #FDF006', '#4FA0FF', '#EB6001', '#BF98FF', '#BF98FF', '#58D9F9']
    },
    width: {
      type: String,
      default: '3.68vw'
    },
    height: {
      type: String,
      default: '2.44vh'
    }
  },
  watch: {
    list(val) {
      this.dataList = val
    }
  },
  mounted() {},
  methods: {}
}
</script>
<style lang="scss" scoped>
.legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  width: 7.7vw;
  height: 8.54vh;
  margin-left: 0.42vw;
  .legend-item {
    // background: #0A214D;
    align-items: center;
    font-size: 12px;
    color: #FFFFFF;
    box-sizing: border-box;
    margin: 2px 2px 2px 0;
    white-space: nowrap;
    .item-content {
      width: 2.8vw;
      overflow: hidden;
    }
    .icon {
      width: 5px;
      height: 5px;
      background: #bf98ff;
      border-radius: 50%;
      margin: 4px;
    }
  }
}
</style>