Android平台下图表绘制相关方法 Android开发技术

  很多网友可能会遇到图表绘制等问题,在Android平台下如何我们需要绘制饼图、K线图应该如何处理呢? 在Android平台下绘图的API大多数由Canvas提供类似Win32或Symbian中的DC,提供大量的绘制方法.

对于饼图即PieChart而言,比较简单,首先计算每个区域的百分比,然后通过drawArc方法绘制弧形,方法原型如下:

  public void drawArc (RectF oval, float startAngle, float sweepAngle, boolean useCenter, Paint paint)

oval  The bounds of oval used to define the shape and size of the arc
startAngle  Starting angle (in degrees) where the arc begins
sweepAngle  Sweep angle (in degrees) measured clockwise
useCenter  If true, include the center of the oval in the arc, and close it if it is being stroked. This will draw a wedge
paint  The paint used to draw the arc 

 对于K线图而言,分为两种:

  1. 静止不动型的

  炒股软件的K线图,这类直接根据数据,在x,y轴上描点即可,比较简单。

  2. 水平滚动型的

  Windows任务管理器的CPU使用了历史记录图表

  相对于这类,使用一个TimerTask不断刷新就可以了,不过要注意的是历史数据数组的溢出问题。一般用于长时间持续显示。

  有关实现的代码Android123将在一周内提供下载,目前还有细节调试中,希望对Android开发者有用。

本人擅长Ai、Fw、Fl、Br、Ae、Pr、Id、Ps等软件的安装与卸载,精通CSS、JavaScript、PHP、ASP、C、C++、C#、Java、Ruby、Perl、Lisp、Python、Objective-C、ActionScript、Pascal等单词的拼写,熟悉Windows、Linux、OS X、Android、iOS、WP8等系统的开关机。

通过下面的方式来联系我们:

电邮:138762189@qq.com

联系QQ:点击这里给我发消息

官方站:www.tadke.com

※ ※ 联系请加我的企鹅号 ※※

※ ※技术支持请微信联系站长 ※※

Copyright © 2023 Tadke.com. 琼ICP备20000547号