Multiple bars and the bottom axis value

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
nisbus
Newbie
Newbie
Posts: 18
Joined: Wed Jan 18, 2006 12:00 am
Location: Iceland
Contact:

Multiple bars and the bottom axis value

Post by nisbus » Wed Apr 04, 2007 2:45 pm

Hi,

I'm plotting multiple BarSeries on a chart, each bar has a single Yvalue and a text X value.

I have tried two different methods

Code: Select all

            ChartSeries.AddXY(Value,Date,DisplayName)
            ChartSeries.AddY(Value,DisplayName)
Note: the date in this case is always the same.

In both cases I get multiple bars but the bottom axis only shows the displayname of the first series.

How can I get them to display each bars displayname on the bottom axis?

Thank you,
nisbus

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

Post by Narcís » Wed Apr 04, 2007 2:48 pm

Hi nisbus,

Yes, this is TeeChart's default behaviour. In that case you should use custom labels as shown in the All Features\Welcome!\Axes\Labels\Custom labels example at the new features demo. You'll find the demo at TeeChart's program group created by the binary installer.
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

nisbus
Newbie
Newbie
Posts: 18
Joined: Wed Jan 18, 2006 12:00 am
Location: Iceland
Contact:

custom bar labels

Post by nisbus » Wed Apr 04, 2007 3:47 pm

Ok, I used the method from the demo and this is a small test:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  ser : TChartSeries;
begin
  Ser := TBarSeries.Create(Self);
  Ser.Name := 'Ser'+IntToStr(Chart1.SeriesCount);
  Ser.ParentChart := Chart1;
  Ser.Title := 'yes';
  Ser.AddXY(Chart1.SeriesCount,Chart1.SeriesCount,Ser.Title);
  Chart1.Axes.Bottom.Items.Add(Chart1.SeriesCount,'yes'+IntToStr(Chart1.SeriesCount));
end;
The problem with this is that the labels don't align with the bars so when I have 4 bars the labels are nowhere near the bottom of the bar.

thanks,
nisbus[/code]

Pep
Site Admin
Site Admin
Posts: 3277
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Apr 11, 2007 7:42 am

Hi,

in that case you sould use similar code to the following one :

Code: Select all

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  ser : TChartSeries;
begin
  Ser := TBarSeries.Create(Self);
  Ser.Name := 'Ser'+IntToStr(Chart1.SeriesCount);
  Ser.ParentChart := Chart1;
  Ser.Title := 'yes';
  Ser.AddXY(Chart1.SeriesCount,Chart1.SeriesCount,Ser.Title);
  Chart1.Axes.Bottom.Items.Add(Chart1.SeriesCount,'yes'+IntToStr(Chart1.SeriesCount));
  (Ser as tBarSeries).MultiBar:=mbNone;
  (Ser as tBarSeries).BarWidthPercent:=5;
end;

Post Reply