vue3饼图展示(附效果图)

const option4 = computed(() => {
    const otherData = shouldPower.value;

    const defaultOption = {
      grid: {
        top: '20%',
        left: 0,
      },
      title: {
        text: '应核发绿证电量',
        left: 'left',
        textStyle: {
          fontSize: 16, // 设置字体大小为12
        },
      },
      tooltip: {
        trigger: 'item',
      },
      series: [
        {
          type: 'pie',
          radius: '50%',
          label: {
            show: true,
            formatter: '{d}%',
            position: 'inside',
            color: '#000',
          },
          data: otherData,
        },
        {
          type: 'pie',
          radius: '50%',
          label: {
            show: true,
            formatter: '{c}万KWh',
          },
          data: otherData,
        },
      ],
    };

    return defaultOption;
  });
  const option5 = computed(() => {
    const otherData = approvePower.value;

    const defaultOption = {
      grid: {
        top: '20%',
        left: 0,
      },
      title: {
        text: '已核发绿证电量',
        left: 'left',
        textStyle: {
          fontSize: 16, // 设置字体大小为12
        },
      },
      tooltip: {
        trigger: 'item',
      },
      series: [
        {
          type: 'pie',
          radius: '50%',
          label: {
            show: true,
            formatter: '{d}%',
            position: 'inside',
            color: '#000',
          },
          data: otherData,
        },
        {
          type: 'pie',
          radius: '50%',
          label: {
            show: true,
            formatter: '{c}张',
          },
          data: otherData,
        },
      ],
    };

    return defaultOption;
  });
  const option6 = computed(() => {
    const defaultOption = {
      title: {
        text: '核发比例排名',
        left: 'left',
        textStyle: {
          fontSize: 16, // 设置字体大小为12
        },
      },
      grid: {
        left: '2%',
        containLabel: true,
      },
      yAxis: {
        type: 'category',
        data: listname.value,
        axisLine: {
          lineStyle: {
            color: '#000',
          },
          show: false,
        },
        axisTick: {
          show: false, // 隐藏 Y 轴刻度
        },
        axisLabel: {
          width: '60', // 将内容的宽度固定
          color: '#000',
          // overflow: 'truncate', // 超出的部分截断
          // truncate: '...', // 截断的部分用...代替
        },
      },
      xAxis: {
        type: 'value',
        axisLine: {
          show: false, // 隐藏 X 轴线
        },
        axisTick: {
          show: false, // 隐藏 X 轴刻度
        },
        splitLine: {
          show: false, // 隐藏 X 轴分割线
        },
        axisLabel: {
          show: false, // 隐藏 Y 轴标签
        },
      },
      // grid: {
      //   bottom: '10%', // 调整底部边距为 10%
      // },
      series: [
        {
          data: reatios.value,
          type: 'bar',
          barWidth: 20,
          itemStyle: {
            color: '#4472C5', // 设置柱子颜色为蓝色
          },
          label: {
            show: true,
            position: 'insideBottom',
            align: 'center',
            color: '#fff',
            formatter: '{c}%',
          },
        },
      ],
    };

    return defaultOption;
  });

  • 8
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要实现Vue 3中的循环播放,你可以按照以下步骤进行操作: 1. 首先,确保你已经安装了Vue 3和相关的数据可视化库。例如,你可以使用`vue-chartjs`或`echarts`等库来创建。 2. 在你的Vue组件中,导入所需的数据可视化库和组件。例如,如果你选择使用`vue-chartjs`,可以这样导入: ```javascript import { Pie } from 'vue-chartjs'; ``` 3. 创建一个新的Vue组件,并继承所选择的数据可视化库提供的组件。例如,继承`Pie`组件: ```javascript export default { extends: Pie, // 其他组件选项 } ``` 4. 在组件中,设置的数据和选项。你可以使用Vue的响应式数据来实时更新。例如,在组件的`data`中定义一个存储数据的数组: ```javascript data() { return { pieData: [ // 数据 ], }; }, ``` 5. 在组件的`mounted`生命周期钩子中,使用父类提供的方法来渲染。例如,使用`this.renderChart()`方法: ```javascript mounted() { this.renderChart(this.pieData, options); }, ``` 6. 然后,你可以编写一个循环函数来更新的数据。根据你的需求,可以使用`setTimeout`或`setInterval`函数来定时调用该函数,并更新数据。例如: ```javascript methods: { startAnimation() { // 循环函数,更新数据 // 使用setTimeout或setInterval来定时调用该函数 } }, ``` 7. 最后,在组件的模板中,使用所选择的数据可视化库提供的组件,并将的容器绑定到组件中定义的元素上。例如,在`<template>`中添加以下代码: ```html <div> <pie :data="pieData"></pie> </div> ``` 这样,你就可以实现Vue 3中的循环播放了。记得根据你选择的数据可视化库的文档和示例进行相应的配置和使用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值