我有一组数据,计算这组数据后得到给类数所占总额的百分比我想根据各类数据的比例画一饼图(圆弧也可,把一圆分成几个扇行)在Bitmap.canvas中如何实现,
Bitmap.Canvas.Arc();
Bitmap.Canvas.Pie();
参数如何设定????
Bitmap.Canvas.Arc();
Bitmap.Canvas.Pie();
参数如何设定????
解决方案 »
- 解释下下面的代码的意思
- delphi报表
- 服务器死机
- 如何提高内存中tbitmap图形的显示和刷新速度
- delphi 报表怎样设计成横向打印?
- 遇到无能的项目负责人,郁闷,散分
- 想听听各大侠对borland的delphi,c++builder支持微软visualstudio.net的看法
- 在DBGrid上执行Query1.Locate定位时,如何让带蓝色背景的选择随游标一起绑定定位
- 请问,access的mdb数据库和delphi的db数据库哪一个好一些?
- 请教delphi中类的一些问题!!
- 【申请】小弟要申请Windows SDK/API的版猪职务,当不上也散分啦!【散分444】
- 请高手指导一下!
共有8个参数,前四个是弧所在的rect的right,top,bottom,left参数
后四个是弧的right,top,bottom,top参数,
例如
canvas.arc(0,800,600,0,0,0,600,800)
具体的自己试一试就okle。
procedure TForm1.Draw(items: array of integer);
var
ox, oy, r, i, sum, a: integer;
f: single;
cls: array of TColor;
begin
sum := 0;// 数值总和
a := 0;// 角度
r := 100;// 半径
ox := 120;// 圆心横坐标
oy := 120;// 圆心纵坐标
// 随机颜色
SetLength(cls, Length(items));
for i := Low(items) to High(items) do
cls[i] := RGB(Random(Random(255)), Round(Random(255)), Round(Random(255)));
for i := Low(items) to High(items) do
Inc(sum, items[i]);
f := 2 * pi / sum;// 角度的系数
for i := Low(items) to High(items) do
begin
Image1.Canvas.Brush.Color := cls[i];
Image1.Canvas.Pie(
ox - r, oy - r,
ox + r, oy + r,
ox + Round(r * cos(f * a)), oy - Round(r * sin(f * a)),
ox + Round(r * cos(f * (a + items[i]))), oy - Round(r * sin(f * (a + items[i]))));
Inc(a, items[i]);
end;
end;测试:
Draw([1,5,3,4,5,6,10,4]);