Paul
Paul

Reputation: 26640

Different axes for different series in TeeChart

I am using TChart with a set of TFastLineSeries, created at run time.

Is it possible to use for a half of series the left axis as Y-axis, for another half - the right one, with individual min/max for each axis?

I don't see properties that can assign axes to series or vice versa.

procedure TForm1.FormShow(Sender: TObject);
var
  sv: TSoundingVol;
  i: Integer;
  serT0, serT05, serUllage, serVCG: TChartSeries;
begin
  sv := TSoundingVol.Create();
  try
    Chart1.ClearChart();
    Chart1.View3D := False;
    Chart1.Legend.CheckBoxes := True;

    Chart1.Axes.Bottom.Title.Text := 'Sounding, m';
    Chart1.Axes.Left.Title.Text := 'Volume, m³';

    serT0 := TFastLineSeries.Create(Chart1);
    serT0.Title := 'At Trim 0 m';

    serT05 := TFastLineSeries.Create(Chart1);
    serT05.Title := 'At Trim +0,5 m (by bow)';

    //Following series should use the right axis and own scaling

    serUllage := TFastLineSeries.Create(Chart1);
    serUllage.Title := 'Ullage (m)';

    serVCG := TFastLineSeries.Create(Chart1);
    serVCG.Title := 'VCG (Vertical Center of Gravity)';

    for i := Low(SB505Data) to High(SB505Data) do begin
      sv.Load(SB505Data[i]);
      serT0.AddXY(sv.Sounding, sv.AtTrim0);
      serT05.AddXY(sv.Sounding, sv.AtTrim0_5);
      serUllage.AddXY(sv.Sounding, sv.Ullage);
      serVCG.AddXY(sv.Sounding, sv.VCG);
    end;
    Chart1.AddSeries(serT0);
    Chart1.AddSeries(serT05);
    Chart1.AddSeries(serUllage);
    Chart1.AddSeries(serVCG);
  finally
    sv.Free();
  end;
end;

Upvotes: 2

Views: 1041

Answers (2)

Max Kleiner
Max Kleiner

Reputation: 1612

The individual min/max for each axis is done by:

 Chart1.RightAxis.SetMinMax(0, 100);
 Chart1.LeftAxis.SetMinMax(10, 8000);

with legend checkboxes you can select each either:

 Chart1.Legend.CheckBoxes:= True;

Full example at: http://www.softwareschule.ch/examples/json5.txt

AGSI data science https://agsi.gie.eu/

Upvotes: 0

Brian
Brian

Reputation: 7289

On a per series basis you can set which Vertical Axis to use.

serUllage.VertAxis := aRightAxis;
serVCG.VertAxis := aRightAxis;

Example of two differently scaled axis used at once.

enter image description here

Upvotes: 5

Related Questions