LineChart Copy.vue 2.78 KB
<script setup lang="ts">
  import { Descriptions, Progress, Skeleton, Tooltip, DescriptionsItem } from 'ant-design-vue';

  defineProps({
    seriesData: {
      type: Array as PropType<Recordable[]>,
      default: () => [],
    },
  });
</script>
<template>
  <div class="m-16">
    <Skeleton active :paragraph="{ rows: 10 }" :loading="!seriesData">
      <Descriptions :column="1">
        <template v-for="(item, index) in seriesData" :key="item.label">
          <DescriptionsItem>
            <span
              class="mr-2 item-span"
              :style="{
                color:
                  index === 0
                    ? '#f0a16e'
                    : index === 1
                    ? '#868585'
                    : index === 2
                    ? '#e78739'
                    : '#4e84f5',
                backgroundColor:
                  index === 0 ? '#FAD672' : index === 1 ? '#CBCAC9' : index === 2 ? '#F1B889' : '',
                borderColor:
                  index === 0
                    ? '#fdee7d'
                    : index === 1
                    ? '#e6e6e5'
                    : index === 2
                    ? '#f8c296'
                    : '#0b55f1',
              }"
              >{{ index + 1 }}</span
            >
            <div class="flex justify-between" style="width: 100%">
              <div class="label-span">
                <Tooltip :title="item.label">
                  {{ item.label }}
                </Tooltip>
              </div>
              <div class="flex w-7/10">
                <Progress
                  :showInfo="false"
                  size="small"
                  style="width: 70%"
                  :percent="(item.value / seriesData[0].value) * 100"
                  :strokeWidth="12"
                  :strokeColor="
                    index === 0
                      ? '#ea5b42'
                      : index === 1
                      ? '#666'
                      : index === 2
                      ? '#e4751a'
                      : '#b5b6b6'
                  "
                />
                <span
                  class="ml-2"
                  :style="{ color: index === 0 ? '#EA5B42' : index === 2 ? '#E4751A' : '#666' }"
                >
                  {{ item.value }}
                </span>
              </div>
            </div>
          </DescriptionsItem>
        </template>
      </Descriptions>
    </Skeleton>
  </div>
</template>

<style scoped lang="less">
  .item-span {
    width: 1.4rem;
    height: 1.25rem;
    border: 1px solid;
    color: #0b55f1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .label-span {
    width: 10rem;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    word-break: break-all;
  }
</style>