hi
I think 2 y axis is the max. I have used a TDBChart(derives from TChart) and added 2 series to one graph. I think if you want to add more than 3 you have to assign them to one of the Y axis and it adjusts to a range suitable for both series.
I've copied and pasted my proc which does this:
procedure TBase.AddSeriesToGraph(sLabel : string; xSelField : Tfield; ySelField : Tfield);
var NewSeries : TLineSeries;
MsgRes : TModalResult;
begin
Application.ProcessMessages;
NewSeries := TLineSeries.Create(self);
NewSeries.ParentChart := OvlGraph.Chart;
NewSeries.DataSource := Query;
NewSeries.CheckDataSource;
NewSeries.LinePen.Width := 2;
NewSeries.SeriesColor := RGB(Random(256), Random(256),Random(256));
OvlGraph.Chart.RightAxis.Increment := 0.0001;
OvlGraph.Chart.LeftAxis.Increment := 0.0001;
if OvlGraph.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;
OvlGraph.Chart.RightAxis.LabelsOnAxis := true;
NewSeries.YValues.ValueSource := ySelField.FieldName;
end;
Application.ProcessMessages;
end;
if OvlGraph.Chart.SeriesCount = 1 then
begin
NewSeries.VertAxis := aLeftAxis;
NewSeries.YValues.ValueSource := ySelField.FieldName;
OvlGraph.Chart.LeftAxis.Title.Caption := ySelField.FieldName;
NewSeries.SeriesColor := RGB(Random(100)+100, Random(100)+100,Random(100)+100);
Application.ProcessMessages;
end;
if OvlGraph.Chart.SeriesCount = 2 then
begin
NewSeries.SeriesColor := RGB(Random(100)+20, Random(100)+20,Random(100)+20);
if OvlGraph.Chart.RightAxis.Title.Caption = '' then
begin
NewSeries.VertAxis := aRightAxis;
OvlGraph.Chart.RightAxis.LabelsOnAxis := true;
NewSeries.YValues.ValueSource := ySelField.FieldName;
OvlGraph.Chart.RightAxis.Title.Caption := ySelField.FieldName;
end
else //insert 2nd one on the left
begin
NewSeries.VertAxis := aLeftAxis;
OvlGraph.Chart.LeftAxis.LabelsOnAxis := true;
NewSeries.YValues.ValueSource := ySelField.FieldName;
OvlGraph.Chart.LeftAxis.Title.Caption := ySelField.FieldName;
end;
Application.ProcessMessages;
end;
if xSelField.DataType = ftDateTime
then NewSeries.XValues.DateTime := true;
NewSeries.XValues.ValueSource := xSelField.FieldName;
OvlGraph.Chart.BottomAxis.Title.Caption := xSelField.FieldName;
OvlGraph.Chart.BottomAxis.Automatic := true;
OvlGraph.Chart.BottomAxis.AdjustMaxMin;
NewSeries.Title := ySelField.FieldName;
SynchRelativeScales;
Application.ProcessMessages;
OvlGraph.Chart.repaint;
Application.ProcessMessages;
end;
Hope this is helpful.
lou