Frequently Asked Component Specific Questions

Options

Display all FAQ items

Search FAQ items:


Displaying items 1 to 1 of 1, page 1 of 1

<< previous next >>

TMS VCL Chart
Using Y-axis values per serie in the chart

Each serie in the chart can have its own Y-axis values. It can be choosen if the Y-axis values for a series should be displayed left or right from the chart. The settings to control this are under Serie.YAxis.Position. When two series have an Y-axis displayed on the same size of the chart, the spacing between the Y-axis itself and value is controlled by Serie.YAxis.MajorUnitSpacing := 30;
In the code sample below, 4 series are added to the chart. Series 1 and 3 have the Y-axis on the left side while series 2 and 4 have the Y-axis on the right side. To make clear what Y-axis belongs to what series, the serie line color is set to the same color as the Y-axis value font.
procedure TForm2.InitChart;
begin
  advchartview1.BeginUpdate;
  advchartview1.Panes[0].Series.Clear;

  with advchartview1.Panes[0].Series.Add do
  begin
    YAxis.Position := yLeft;
    YAxis.MajorUnitSpacing := 30;
    YAxis.MajorFont.Color := clRed;
    AddSinglePoint(0);
    AddSinglePoint(15);
    AddSinglePoint(17);
    AddSinglePoint(18);
    LineColor := clRed;
    AutoRange := arEnabled;
  end;

  with advchartview1.Panes[0].Series.Add do
  begin
    YAxis.Position := yRight;
    YAxis.MajorUnitSpacing := 30;
    YAxis.MajorFont.Color := clGreen;
    AddSinglePoint(150);
    AddSinglePoint(100);
    AddSinglePoint(120);
    AddSinglePoint(190);
    LineColor := clGreen;
    AutoRange := arEnabled;
  end;

  with advchartview1.Panes[0].Series.Add do
  begin
    YAxis.Position := yLeft;
    YAxis.MajorFont.Color := clBlue;
    AddSinglePoint(20);
    AddSinglePoint(25);
    AddSinglePoint(27);
    AddSinglePoint(28);
    LineColor := clBlue;
    AutoRange := arEnabled;
  end;

  with advchartview1.Panes[0].Series.Add do
  begin
    YAxis.Position := yRight;
    YAxis.MajorFont.Color := clYellow;
    AddSinglePoint(250);
    AddSinglePoint(200);
    AddSinglePoint(210);
    AddSinglePoint(380);
    LineColor := clYellow;
    AutoRange := arEnabled;
  end;

  advchartview1.Panes[0].YAxis.Position := yBoth;
  advchartview1.Panes[0].YAxis.Size := 150;
  advchartview1.Panes[0].Range.RangeFrom := 0;
  advchartview1.Panes[0].Range.RangeTo := 3;
  advchartview1.EndUpdate;
end;