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

vue2+echarts实现水球+外层动效

实现效果

在这里插入图片描述

安装echarts-liquidfill

  • 需要安装echarts-liquidfill!!!
  • 需要安装echarts-liquidfill!!!
  • 需要安装echarts-liquidfill!!!
安装命令
npm install echarts-liquidfill
版本如图:

在这里插入图片描述

实现代码

  data() {return {chart: null,timer: null,angle: 0, //角度,用来做简单的动画效果的list: [],/* this.list = [rate,{value: rate,direction: "left", //波浪方向},]; */};},mounted() {this.$nextTick(() => {this.initChart();});},beforeDestroy() {if (!this.chart) {return;}this.chart.dispose();clearInterval(this.timer); // 销毁前,清除时间定时器this.timer = null;},methods: {initChart() {this.chart = this.$echarts.init(this.$refs.chart3Ref);let that = this;let option = {series: [{name: "内线",type: "custom",coordinateSystem: "none",renderItem: function (params, api) {return {type: "arc",shape: {cx: api.getWidth() / 2,cy: api.getHeight() / 2,r: Math.min(api.getWidth(), api.getHeight()) / 2.3,startAngle: ((0 + that.angle) * Math.PI) / 180,endAngle: ((90 + that.angle) * Math.PI) / 180,},style: {stroke: "#0ff",fill: "transparent",lineWidth: that.fontSize(0.03),},silent: true,};},data: [0],},{name: "内线",type: "custom",coordinateSystem: "none",renderItem: function (params, api) {return {type: "arc",shape: {cx: api.getWidth() / 2,cy: api.getHeight() / 2,r: Math.min(api.getWidth(), api.getHeight()) / 2.3,startAngle: ((180 + that.angle) * Math.PI) / 180,endAngle: ((270 + that.angle) * Math.PI) / 180,},style: {stroke: "#0ff",fill: "transparent",lineWidth: that.fontSize(0.03),},silent: true,};},data: [0],},{name: "外线",type: "custom",coordinateSystem: "none",renderItem: function (params, api) {return {type: "arc",shape: {cx: api.getWidth() / 2,cy: api.getHeight() / 2,r: Math.min(api.getWidth(), api.getHeight()) / 2.1,startAngle: ((270 + -that.angle) * Math.PI) / 180,endAngle: ((40 + -that.angle) * Math.PI) / 180,},style: {stroke: "#0ff",fill: "transparent",lineWidth: that.fontSize(0.03),},silent: true,};},data: [0],},{name: "外线",type: "custom",coordinateSystem: "none",renderItem: function (params, api) {return {type: "arc",shape: {cx: api.getWidth() / 2,cy: api.getHeight() / 2,r: Math.min(api.getWidth(), api.getHeight()) / 2.1,startAngle: ((90 + -that.angle) * Math.PI) / 180,endAngle: ((220 + -that.angle) * Math.PI) / 180,},style: {stroke: "#0ff",fill: "transparent",lineWidth: that.fontSize(0.03),},silent: true,};},data: [0],},{name: "线头点",type: "custom",coordinateSystem: "none",renderItem: function (params, api) {let x0 = api.getWidth() / 2;let y0 = api.getHeight() / 2;let r = Math.min(api.getWidth(), api.getHeight()) / 2.1;let point = that.getCirlPoint(x0, y0, r, 90 + -that.angle);return {type: "circle",shape: {cx: point.x,cy: point.y,r: 5,},style: {stroke: "#0ff", //绿fill: "#0ff",},silent: true,};},data: [0],},{name: "线头点",type: "custom",coordinateSystem: "none",renderItem: function (params, api) {let x0 = api.getWidth() / 2;let y0 = api.getHeight() / 2;let r = Math.min(api.getWidth(), api.getHeight()) / 2.1;let point = that.getCirlPoint(x0, y0, r, 270 + -that.angle);return {type: "circle",shape: {cx: point.x,cy: point.y,r: 5,},style: {stroke: "#0ff", //绿fill: "#0ff",},silent: true,};},data: [0],},{// value: 50, //  内容 配合formattertype: "liquidFill",radius: "70%", // 控制中间圆球的尺寸(此处可以理解为距离外圈圆的距离控制)center: ["50%", "50%"],data: this.list, // data个数代表波浪数backgroundStyle: {borderWidth: this.fontSize(0.01),color: "rgba(62, 208, 255, 1)", // 球体本景色},amplitude: "6  %", //波浪的振幅// 修改波浪颜色color: [{type: "linear",x: 0,y: 0,x2: 0,y2: 1,colorStops: [{offset: 1,color: "#6CDEFC",},{offset: 0,color: "#429BF7",},],globalCoord: false,},],label: {normal: {formatter: function (params) {return params.value * 100 + " %";},textStyle: {fontSize: this.fontSize(0.3),color: "#fff",},},},backgroundStyle: {borderWidth: that.fontSize(0.01),color: "transparent",},outline: {show: true,itemStyle: {borderColor: "#0ff",borderWidth: that.fontSize(0.02),},borderDistance: that.fontSize(0.03),},},{type: "pie",z: 1,center: ["50%", "50%"],radius: ["72%", "75%"], // 控制外圈圆的粗细hoverAnimation: false,data: [{name: "",value: 0,labelLine: {show: false,},itemStyle: {color: "#00AFFF",},emphasis: {labelLine: {show: false,},},},],},],};this.chart.setOption(option);this.timer = setInterval(() => {this.draw();}, 100);},getCirlPoint(x0, y0, r, angle) {let x1 = x0 + r * Math.cos((angle * Math.PI) / 180);let y1 = y0 + r * Math.sin((angle * Math.PI) / 180);return {x: x1,y: y1,};},draw() {this.angle = this.angle + 3;let option = this.chart.getOption();// console.log(option, "option");option.series[6].data = this.list;this.chart.setOption(option);},},
http://www.lryc.cn/news/514250.html

相关文章:

  • C++ 基础思维导图(一)
  • 【gopher的java学习笔记】依赖管理方式对比(go mod maven)
  • CTFshow—远程命令执行
  • Qt之简易音视频播放器设计(十五)
  • ArrayList 和LinkedList的区别比较
  • Wallpaper壁纸制作学习记录13
  • Visual Studio 2022安装教程
  • std__invoke 的使用
  • 2501d,d.109
  • 1、蓝牙打印机环境搭建
  • Axure RP11安装学习
  • axios和fetch的实现原理以及区别,与XMLHttpRequest的关系,并结合react封装统一请求示例
  • 矩阵运算提速——玩转opencv::Mat
  • C++软件设计模式之模板方法模式
  • 神经网络的初始化方式都有哪些?
  • const成员函数
  • 物理知识1——电流
  • 车载通信架构 --- 智能汽车通信前沿技术
  • Flutter中添加全局防护水印的实现
  • BGP(Border Gateway Protocol)路由收集器
  • 【DAGMM】直接跑tip
  • vscode中调用deepseek实现AI辅助编程
  • AI大模型语音识别转文字
  • 可由 (5V) 单片机直接驱动的模块
  • vue使用树形结构展示文件和文件夹
  • PHP框架+gatewayworker实现在线1对1聊天--聊天界面布局+创建websocket连接(5)
  • LinuxUbuntu打开VSCode白屏解决方案
  • 在 ESP 上运行 AWTK
  • 硬件工程师面试题 21-30
  • 开源架构的容器化部署优化版