Page 1 of 1

Multiple bars and the bottom axis value

Posted: Wed Apr 04, 2007 2:45 pm
by 9345006
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

Posted: Wed Apr 04, 2007 2:48 pm
by narcis
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.

custom bar labels

Posted: Wed Apr 04, 2007 3:47 pm
by 9345006
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]

Posted: Wed Apr 11, 2007 7:42 am
by Pep
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;