Chart问题,在线等待

hongss 2003-05-20 09:54:00
请教大侠:
那里能找到圆形的Chart控件?

就像是把一个chart的首尾相接一样。

如果不借助第三方控件怎么实现?

...全文
102 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
yzykjh 2003-07-14
  • 打赏
  • 举报
回复
动态生成控件方法的应用
 

---- 在开发生产调度与管理系统中,需要动态生成排产计划图,以甘特图表示,应用Shape控件来显示零件的加工状况(每道工序的加工开始时间与结束时间)是非常适合的。应用Chart控件,对加工设备利用率以三维直方图显示,非常直观。现分别将在程序中动态生成Shape控件和Chart控件的过程加以说明。

---- 1、动态生成Shape控件显示排产计划图(甘特图)

procedure TCreateMultiCharts.ProcCreateCharts;
var
i,j,Rows,Columns,RowSpace,ChartsHeight:Integer;
ShapeChart:array of array of TShape;
begin
Rows:=16; //Shape控件数组行数
Columns:=8; // Shape控件数组列数
RowSpace:=20; // Shape控件行间距
ChartsHeight:=20; // Shape控件高度
SetLength(ShapeChart,Rows,Columns);
//设置ShapeChart数组大小
for i:=0 to Rows do
for j:=0 to Columns do
begin
ShapeChart[i][j]:=TShape.Create(self);
with ShapeChart[i,j] do
begin
Parent:=Self; //此行必不可少,
否则Shape控件在屏幕显示不出
Shape:=stRectangle; // Shape控件形状为矩形
Top:=45+i*(RowSpace+ChartsHeight);
Left:=Round(180+Q[i,j].StartTime);
//因Q[i,j].StartTime为实数,故需进行四舍五入取整
Width:=Round(Q[i,j].Value)
Height:=ChartsHeight;
Brush.Color:=RandomColor;
//自定义函数,说明附后
Brush.Style:=bsSolid; //设置填充方式
Enabled:=True;
end;
end;
end;
 

---- 注:

---- (1)Q为一记录型二维数组,定义如下:

type
TempData=Record
Value:Real;
StartTime:Real;
end;
Q:array of array of TempData
 

---- 并且在另一过程已对Q的分量进行赋值。

---- (2)为了区分不同的零件,Shape以不同颜色显示,此时,调用了函数RandomColor。该函数为:

function TCreateMultiCharts.RandomColor;
var
red,green,blue:byte;
begin
red:=random(255);
green:=random(255);
blue:=random(255);
result:=red or (green shl 8) or (blue shl 16);
end;
---- 2、动态生成Charts控件的ChartSeries组件,显示设备利用率

procedure TFormMultiMachinesBurthen.
ShowMachineBurthenCharts;
var
i:Integer;
Burthen:Real;
SeriesClass:TChartSeriesClass;
NewSeries:array of TChartSeries;
begin
SetLength(NewSeries,CreateMultiCharts.Rows);
MachinesBurthenCharts.height:=200;
MachinesBurthenCharts.Width:=550;
for i:=0 to CreateMultiCharts.Rows do
begin
SeriesClass:=TBarSeries; //设置形状为三维条形图
NewSeries[i]:=SeriesClass.Create(Self);
NewSeries[i].ParentChart:=MachinesBurthenCharts;
NewSeries[i].Clear;
Burthen:=MachineBurthen[i];
Burthen:=Round(Burthen*100)/100; //只取小数点后两位数字
NewSeries[i].add(Burthen,'',NewSeries[i].SeriesColor);
end;
end;
yzykjh 2003-07-14
  • 打赏
  • 举报
回复
下面是简单的例子:
var
i, j, kum: Integer;
s, t: TBarSeries;
begin
with Chart1 do
begin
// Title of the Chart
SeriesList.Clear;
Title.Text.Clear;
Title.Text.Add('My Title for Char');
Legend.Visible :=True;
Legend.LegendStyle :=lsAuto;
Legend.TextStyle := ltsLeftValue;
// Create first Series
s := TBarSeries.Create(nil);
// Clear it
s.Clear;
s.BarStyle :=bsRectGradient;
s.ColorEachPoint :=True;
// set the title
s.Title := 'Bar 1';
// determine the chart, this series belongs to
s.ParentChart := Chart1;
// the x-axis shall use date
s.XValues.DateTime := False;
s.AutoBarSize :=False;
s.BarWidthPercent := 70;
s.OffsetPercent :=0;
s.Marks.Style :=smsPercent;
// create the second Series
t := TBarSeries.Create(nil);
t.Clear;
t.Title := 'Bar 2';
t.ParentChart := Chart1;
t.XValues.DateTime := False;
// this series uses the right axis
t.VertAxis := aLeftAxis;
// now add the random values
Randomize;
for i := 0 to 5 do
begin
j := Random(100) + 1;
s.AddXY(i, j);
kum := j;
t.AddXY(i , kum + Random(20));
end;
end;

hongss 2003-07-14
  • 打赏
  • 举报
回复
晕~~~

我要的是一个画圆的工具:只要画出一个圆圈,不要中间的部分!
就是说:
我现在从下位机接受数据,然后在屏幕上画出圆来。而且要接收120个数据画出一个圆,要反映出这段时间里,这些数据的变化情况。确切的说,这样画出来的图形并不是一个“圆”,而是一个类似于圆圈的图形。

请问:有这样的控件吗?

谢谢!
things 2003-07-09
  • 打赏
  • 举报
回复
看1楼的
lincanwen 2003-07-09
  • 打赏
  • 举报
回复
不明白意思
你添加一个Addtional页的Chart,然后双击该控件,然后点击"Add",选择第二排第二个"Pie",看看可以不

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧