惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
大猫的无限游戏
大猫的无限游戏
J
Java Code Geeks
MongoDB | Blog
MongoDB | Blog
Martin Fowler
Martin Fowler
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
F
Fortinet All Blogs
B
Blog
U
Unit 42
B
Blog RSS Feed
D
DataBreaches.Net
Google DeepMind News
Google DeepMind News
人人都是产品经理
人人都是产品经理
腾讯CDC
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Visual Studio Blog
博客园 - 聂微东
MyScale Blog
MyScale Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 三生石上(FineUI控件)
Engineering at Meta
Engineering at Meta

博客园 - zhaogaojian

Qt 5 界面闪烁与白屏问题的原因及解决办法 开发的一款IOTLink,物联网调试工具集 禁用嵌入式设备自动命名usb网卡成enxXXXXX 关闭vEthernet (Default Switch) windows设备2通过linux设备1上网 windows下的/data目录 VSCode创建launch.json的作用 Linux启动时候Ip有时候不显示问题 Android Release模式下无法运行一例解决方法 修改了命名空间后ActivityMainBinding使用爆红 Android MPAndroidChart设置折线点为横轴+纵轴数据 Android停止蓝牙扫描不起作用 MiniCom打开回显 一例ssh无法连接问题 一例串口输出异常问题 Ubuntu14.04 设置共享文件夹 2、el-image设置error图像 1、自定义上传组件实现动态指定action Android 手机生成文件电脑上看不见 Android 一例Base64错误问题
3、使用ECharts控件
zhaogaojian · 2023-12-07 · via 博客园 - zhaogaojian

这个示例使用了 ECharts 的饼图,并使用了 Vue.js 的生命周期钩子函数 mounted 来在组件挂载后初始化图表。在 data 中,chartData 存储了图表的数据,chartColors 存储了图表的颜色配置。在 methods 中,initECharts 方法用于初始化 ECharts 实例和配置项。

<template>
  <div>
    <!-- ECharts 图表容器 -->
    <div class="chart-container" ref="chart"></div>
  </div>
</template>

<script>
import * as echarts from 'echarts';

export default {
  data() {
    return {
      // 模拟的图表数据
      chartData: {
        xAxisData: ['A', 'B', 'C'],
        seriesData: [5, 3, 5],
      },
      // 图表颜色配置
      chartColors: ['#3398DB', '#FF6666', '#3CB371', '#FFD700', '#8B4513'],
    };
  },
  mounted() {
    // 使用固定数据配置 ECharts 实例
    this.initECharts();
  },
  methods: {
    initECharts() {
      const chartDom = this.$refs.chart;
      const myChart = echarts.init(chartDom);

      // ECharts 配置项
      const option = {
        title: {
          text: '示例数据',
          left: 'center',
          top: 20,
          textStyle: {
            fontSize: 16,
            fontWeight: 'bold',
          },
        },
        series: [{
          name: '示例数据',
          type: 'pie',
          radius: '55%',
          center: ['50%', '50%'],
          data: this.chartData.xAxisData.map((name, index) => ({
            name,
            value: this.chartData.seriesData[index],
            itemStyle: {
              color: this.chartColors[index % this.chartColors.length],
            },
          })),
          label: {
            show: true,
            formatter: '{b} : {c} ({d}%)',
          },
        }],
      };

      // 使用配置项设置图表
      myChart.setOption(option);
    },
  },
};
</script>

<style scoped>
.chart-container {
  height: 300px;
  /* 设置图表容器的高度 */
}
</style>