Display of labels from two series in the same chart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
decis
Newbie
Newbie
Posts: 4
Joined: Tue Mar 25, 2008 12:00 am

Display of labels from two series in the same chart

Post by decis » Tue Apr 01, 2008 8:46 am

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Apr 01, 2008 8:56 am

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;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

decis
Newbie
Newbie
Posts: 4
Joined: Tue Mar 25, 2008 12:00 am

Thanks!

Post by decis » Tue Apr 01, 2008 9:12 am

Hello,

That works. Thanks a lot for the fast support.

Ana

Post Reply