Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add Series to a DBChart in Runtime

Status
Not open for further replies.

luistsousa

Technical User
May 12, 2003
66
PT
Hi

Can I create a serie to a DBChart in runtime?

Regards
Luis
 
hi

Here's a snippet from my code, which should help you get started

procedure TBase.AddSeriesToGraph(sLabel : string; xSelField : Tfield; ySelField : Tfield);
var NewSeries : TLineSeries;
MsgRes : TModalResult;
begin
Application.ProcessMessages;
NewSeries := TLineSeries.Create(self);
NewSeries.ParentChart := Chart;
NewSeries.DataSource := Query;
NewSeries.CheckDataSource;
NewSeries.LinePen.Width := 1;
NewSeries.SeriesColor := RGB(Random(256), Random(256),Random(256));

Chart.RightAxis.Increment := 0.0001;
Chart.LeftAxis.Increment := 0.0001;

if Chart.SeriesCount > 2 then
begin
MsgRes := MessageDlg('Scale to Left Axis or Right Axis ? (Yes = Left, No = Right)',
mtConfirmation,[mbyes,mbno, mbCancel],0);
if MsgRes = MRCancel then
begin
NewSeries.Free;
Exit;
end;
if MsgRes = mrYes then
begin
NewSeries.VertAxis := aLeftAxis;
NewSeries.YValues.ValueSource := ySelField.FieldName;
end
else
begin //result = mrNo
NewSeries.VertAxis := aRightAxis;
Chart.RightAxis.LabelsOnAxis := true;
NewSeries.YValues.ValueSource := ySelField.FieldName;
end;
Application.ProcessMessages;
end;
if Chart.SeriesCount = 1 then
begin
NewSeries.VertAxis := aLeftAxis;
NewSeries.YValues.ValueSource := ySelField.FieldName;
Chart.LeftAxis.Title.Caption := ySelField.FieldName;
NewSeries.SeriesColor := RGB(Random(100)+100, Random(100)+100,Random(100)+100);
Application.ProcessMessages;
end;


:

lou

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top