Page 1 of 1

Display of labels from two series in the same chart

Posted: Tue Apr 01, 2008 8:46 am
by 10048721
Hello,

We're having a problem in the display of labels from two series in the same chart.
Example: we create two LineSeries and we fill the values of those series giving for each value a different label. In the chart we see the two series but in the bottom axis we see only the labels from the fisrt serie.
We are using Teechart8 for Delphi6.

procedure TfmTestTeeChart.LoadData;
var
i,j : integer;
jSerie : TChartSeries;
begin
chart1.FreeAllSeries;
chart1.Title.Text.Text := 'Test labels';
//First serie
jSerie := TLineSeries.Create(chart1);
TLineSeries(jSerie).stairs := true;
chart1.AddSeries(jSerie);
jSerie.Title := 'SerieA';
jSerie.Identifier := 'A';

jSerie.AddXY(39479,109,'A1');
jSerie.AddXY(39483,155,'A2');
jSerie.AddXY(39488,184,'A3');
jSerie.AddXY(39493,111,'A4');
jSerie.AddXY(39498,58,'A5');
//Second serie
jSerie := TLineSeries.Create(chart1);
TLineSeries(jSerie).stairs := true;
chart1.AddSeries(jSerie);
jSerie.Title := 'SerieB';
jSerie.Identifier := 'B';

jSerie.AddXY(39455,125,'B1');
jSerie.AddXY(39462,800,'B2');
jSerie.AddXY(39469,140,'B3');
jSerie.AddXY(39471,108,'B4');
jSerie.AddXY(39476,116,'B5');
end;

What can we do in order to see the labels from all the series present in one chart?

Thanks for your attention,
Ana Fróis

Posted: Tue Apr 01, 2008 8:56 am
by narcis
Hi Ana,

Yes, this is by design. When series have text labels chart automatically only displays first series labels. You can solve your problem using custom axis labels as shown on the code below.

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var
  i,j : integer;
  jSerie : TChartSeries;
begin
  chart1.FreeAllSeries;
  chart1.Title.Text.Text := 'Test labels';
  //First serie
  jSerie := TLineSeries.Create(chart1);
  TLineSeries(jSerie).stairs := true;
  chart1.AddSeries(jSerie);
  jSerie.Title := 'SerieA';
  jSerie.Identifier := 'A';

  jSerie.AddXY(39479,109,'A1');
  jSerie.AddXY(39483,155,'A2');
  jSerie.AddXY(39488,184,'A3');
  jSerie.AddXY(39493,111,'A4');
  jSerie.AddXY(39498,58,'A5');
  //Second serie
  jSerie := TLineSeries.Create(chart1);
  TLineSeries(jSerie).stairs := true;
  chart1.AddSeries(jSerie);
  jSerie.Title := 'SerieB';
  jSerie.Identifier := 'B';

  jSerie.AddXY(39455,125,'B1');
  jSerie.AddXY(39462,800,'B2');
  jSerie.AddXY(39469,140,'B3');
  jSerie.AddXY(39471,108,'B4');
  jSerie.AddXY(39476,116,'B5');

  Chart1.Axes.Bottom.Items.Clear;

  for i:=0 to Chart1.SeriesCount -1 do
    for j:=0 to Chart1[i].Count - 1 do
      Chart1.Axes.Bottom.Items.Add(Chart1[i].XValue[j],Chart1[i].Labels[j]);
end;

Thanks!

Posted: Tue Apr 01, 2008 9:12 am
by 10048721
Hello,

That works. Thanks a lot for the fast support.

Ana