关于在表格中画柱状图(50分)

H

Haishen

Unregistered / Unconfirmed
GUEST, unregistred user!
1.我想在一个类似StringGrid的表格控件中显示两列数据,第一列是一个百分比的数据,后面
一列是对应这个百分比的柱状图,(注:是一个横向的柱图,以此列的列宽为100%大小,
主要是更形象的反映前面的百分比数值)

请问大家应该如何做,或有没有什么控件可以完成!

2.再请问大家一件事,有没有人知道Chart这个控件,当其为柱形图或拆线图时,Y轴及横轴
标尺的算法,如:我给了它100条数据,我想知道Chart控件,把它的宽度除以多少做为刻度
的宽度,并且两边各留多少。

如知道请回答,谢谢!
 
只是演示一下方法:在成CELL[1,1]中生成横棒图 CELL[1,2]中生成竖棒图
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if (ACol=1) and (ARow=1) then
begin
with StringGrid1.Canvas do
begin
Brush.Style := bsSolid;
Brush.Color := clRed;
Pen.Color := clBlue;
Rectangle(Rect.Left,Rect.Top+4,Rect.Right-4,Rect.Bottom-4);
end;
end;

if (ACol=1) and (ARow=2) then
begin
with StringGrid1.Canvas do
begin
Brush.Style := bsSolid;
Brush.Color := clRed;
Pen.Color := clBlue;
Rectangle(Rect.Left+14,Rect.Top+4,Rect.Right-14,Rect.Bottom);
end;
end;
end;

你可以继承TDrawGrid并重载
procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); override;根据据上面
所给的列子给于控制即生成你自已的控件 ,可以完成很多你个人相要的功能
 
接受答案了.
 
顶部