当前位置: 首页 > news >正文

Echarts——使用graphic组件在一个option内同时设置两个饼图的背景图

使用echarts的graphic原生图形元素组件,为两个饼图设置对应背景。

在这里插入图片描述
在这里插入图片描述

<template><div id="app"><div class="charts" ref="charts"></div></div>
</template><script>
import * as echarts from 'echarts'export default {name: 'App',mounted () {this.$nextTick(() => {this.init()})},methods: {init () {const pieItemStyle = {// 设置itemStyle的背景色、文本标签、以及文本标签引导线normal: {label: {show: false},labelLine: { show: false },color: 'transparent'}}const option = {tooltip: {},// 通过graphic对象同时设置两张背景图,通过设置top、right、bottom和lefe的值来调整位置graphic: {elements: [{type: 'image',style: {image: require('./assets/pd-bg-done.png'),height: 300},left: '20%',top: 0,bottom: 0},{type: 'image',style: {image: require('./assets/pd-bg-nodone.png'),height: 300},right: '20%',top: 0,bottom: 0}]},series: [{type: 'pie',radius: '50%',center: ['30%', '50%'], // 设置饼图的中心点,让数据显示于对应的背景图上emphasis: {disabled: true,focus: 'none'},itemStyle: pieItemStyle,data: [{value: 123,label: {show: true,position: 'center',formatter: () => {return `{num|123}\n{type|已完成}`},rich: {num: {color: '#047bdf',fontSize: 26,fontWeight: 700,padding: [0, 0, 4, 0]},type: {fontSize: 14,color: '#222F40'}}}}]},{type: 'pie',radius: '50%',center: ['86%', '50%'],emphasis: {disabled: true,focus: 'none'},itemStyle: pieItemStyle,data: [{value: 456,label: {show: true,position: 'center',formatter: () => {return `{num|456}\n{type|未完成}`},rich: {num: {color: '#ea853c',fontSize: 26,fontWeight: 700,padding: [0, 0, 4, 0]},type: {fontSize: 14,color: '#222F40'}}}}]}]}const chartDom = echarts.init(this.$refs.charts)chartDom.setOption(option)}}
}
</script><style scoped>
html, body, #app {width: 100%;height: 100%;
}
.charts {width: 100%;height: 300px;
}
</style>

具体效果:

效果图

http://www.lryc.cn/news/276780.html

相关文章:

  • 编程笔记 html5cssjs 027 HTML输入属性(1/2)
  • 请求参数乱码问题
  • 【leetcode】力扣热门之反转链表【简单难度】
  • 【sgPasswordInput】自定义组件:带前端校验密码强度的密码输入框,能够提供密码强度颜色提示和文字提示
  • 1599 - Ideal Path (UVA)
  • 计算机网络(超级详细笔记)
  • 老杨说运维 | 年末大讲回顾:运维的尽头也是大模型吗?
  • Unity 利用UGUI之Scrollbar制作进度条
  • MySQL之导入、导出
  • 【unity小技巧】FPS游戏实现相机的偏移震动、武器射击后退和后坐力效果
  • MINCO+汽车
  • 大模型机器人发展史:从VoxPoser、RT2到斯坦福Mobile ALOHA、Google机器人
  • Ubunutu18.04 ROS melodic 无人机 XTDrone PX4 Vins-Fuison 运行配置
  • Linux 常见服务配置
  • Flutter基础
  • MySQL-数据库概述
  • HTML---JQurey的基本使用
  • 搜索docker镜像
  • 旋变检测AD2s1205手册学习笔记
  • 【温故而知新】JavaScript的防抖与节流
  • C++模板——(3)类模板
  • 深度学习中Epoch和Batch Size的关系
  • Python采集微博评论做词云图
  • 一文详解VScode 的远程开发
  • 捕捉“五彩斑斓的黑”:锗基短波红外相机的多种成像应用
  • 解读 Sobit v2:铭文资产跨链更注重安全、易用性
  • [开源]万界星空开源MES系统,支持低代码大屏设计
  • 开源软件运维安全防护的六个手段
  • 开启Android学习之旅-5-Activity全屏
  • 运行时类型信息 typeid、type_info...(C++)