excel图表绘制轨迹动画
时间:2023-03-08 15:37:17
本文,我们将在这两篇文章介绍的技巧的基础上,实现绘制圆形轨迹运动,如图1所示。
图1
下图2是我们在图中所使用的数据,本文仍然使用这些数据。
图2
首先,定义一些名称。
名称:n
引用位置:=25
名称:ndx
引用位置:=1
名称:circle_x
引用位置:=OFFSET(Sheet1!$C$2,0,0,n,1)
名称:circle_y
引用位置:=OFFSET(Sheet1!$D$2,0,0,n,1)
名称:dot_circle_x
引用位置:=INDEX(circle_x,ndx)
名称:dot_circle_y
引用位置:=INDEX(circle_y,ndx)
图3为我们在《Excel图表学习06:画圆》中绘制的圆。
图3
选择已经绘制的圆系列,单击右键,选取“设置数据系列格式”。在弹出的“设置数据系列格式”对话框中,将“数据标记选项”设置为“无”,将“线条颜色”设置为“无线条”。此时,图表如图4所示。
图4
我们看到,已经绘制的圆不见了,这是我们的设置造成的,实际上这个圆仍然存在于绘图区中。
下面,我们来添加数据系列。
选中绘图区,在“图表工具”选项卡组中选择“设计”选项卡下的“选择数据”命令,添加数据系列dot_circle,如图5所示。
图5
注意,如果此时在绘图区看不到任何东西,那么需要设置数据系列“dot_circle”的线条颜色为“实线”。
在工作表中插入一个ActiveX控件命令按钮,将其标题更改为“圆形轨迹运动”,双击该按钮并输入下面的代码:
Private i As Long
PrivateblnRunning As Boolean
Private SubCommandButton1_Click()
Dim nm As Names
Dim z As Long
Const DELAY_FACTOR = 1000
If CommandButton1.Caption = “圆形轨迹运动” Then
CommandButton1.Caption = “停止运动”
End If
If blnRunning Then
blnRunning = False
CommandButton1.Caption = “圆形轨迹运动”
Exit Sub
End If
blnRunning = True
Application.Cursor = xlNorthwestArrow
Set nm = Application.Names
Do
If blnRunning = False Then Exit Do
i = i + 1
If i > 25 Then i = 1
nm.Add “ndx”, (i Mod [n]) + 1
For z = 1 To DELAY_FACTOR: DoEvents:Next z
Loop
Application.Cursor = xlDefault
blnRunning = False
Set nm = Nothing
End Sub
退出“设计模式”,然后单击命令按钮,就可以看到圆的轨迹运动的动画了,如图6所示。
图6
细心的读者可能会注意到,圆点的运动轨迹似乎并不圆,这是由于我们绘制时使用的数据点较少造成的,增加一些数据,效果会更好。
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
win8系统重装后IE磁贴无法打开怎么办
![](https://img.aspxhome.com/file/2023/29/a262092_0s.png)
如何解决Word文档在别的电脑上行距变宽的问题
![](https://img.aspxhome.com/file/2023/6/29546_0s.jpg)
Win7恢复dll动态链接库的步骤
![](https://img.aspxhome.com/file/2023/27/a232806_0s.jpg)
「Mac技巧」屏保设置不生效的解决办法
![](https://img.aspxhome.com/file/2023/6/a211786_0s.jpeg)
Win10玩永劫无间游戏启动失败或其他游戏运行问题解决方法
![](https://img.aspxhome.com/file/2023/1/a279846_0s.png)
Win11更新22449.1000怎么会出现评估副本
![](https://img.aspxhome.com/file/2023/27/a237821_0s.png)
WPS word如何将英文下的波浪线去除
![](https://img.aspxhome.com/file/2023/9/a185249_0s.png)
win7如何建立局域网
![](https://img.aspxhome.com/file/2023/29/a262122_0s.png)
免费在线看电影的方法 全网VIP视频免费观看步骤介绍
![](https://img.aspxhome.com/file/2023/6/a326017_0s.jpg)
PowerPoint2007文件格式
如何在wps表中使用条件格式
![](https://img.aspxhome.com/file/2023/3/a170733_0s.jpg)
Edraw max for Mac亿图软件备份文件怎么恢复?
![](https://img.aspxhome.com/file/2023/9/a213989_0s.jpeg)
看Safari如何泄露你的帐号密码?超容易破解!
石墨文档怎么进行高级筛选?石墨文档进行高级筛选的方法
![](https://img.aspxhome.com/file/2023/30/a269276_0s.jpg)
wifi无线网络要如何设置才安全有什么技巧
快速解决升级Win10没有boot.wim的解决方法
![](https://img.aspxhome.com/file/2023/2/a287748_0s.jpg)
iOS 14 桌面找不到应用图标怎么办?
![](https://img.aspxhome.com/file/2023/0/a194410_0s.png)
excel 只复制数字不复制公式的方法
![](https://img.aspxhome.com/file/2023/9/a162309_0s.png)
2个PPT简单制作9宫格的方法 超火朋友圈九宫格照片怎么做?用PPT手
飞信密码忘记了怎么办?
![](https://img.aspxhome.com/file/2023/9/a340733_0s.jpg)