Question about stacked bar chart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
PhilG
Newbie
Newbie
Posts: 3
Joined: Mon Jan 12, 2004 5:00 am

Question about stacked bar chart

Post by PhilG » Mon Mar 29, 2004 10:32 am

Hi,

I have two stacked bar charts (each with three stacks) that work fine, but I
would really like to combine the two into one graph. What I would like is to
have two rows of the three stacks one behind the other. Is this possible ?
If so, how ?

I'm using TChart ver 7 on Delphi 7.

Cheers,
Phil.

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

Post by Pep » Mon Mar 29, 2004 11:52 am

Hi Phil,

yes, how about creating custom axes and using the StackGroup ? I've been able to create an example using the following code :

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var i : integer;
    CustomVertAxis,CustomHorizAxis : TChartAxis;
begin
Chart1.View3D := false;

for i := 0 to 5 do
begin
  Chart1[i].FillSampleValues(5);
  Chart1[i].Marks.Visible := false;
  (Chart1[i] as TBarSeries).MultiBar := mbStacked;
end;

for i:= 0 to 2 do begin
  (Chart1[i] as TBarSeries).StackGroup := 1;
  (Chart1[i] as tbarSeries).OffsetPercent := 50;
end;

CustomVertAxis:=TChartAxis.Create(Chart1);
CustomHorizAxis:=TChartAxis.Create(Chart1);
CustomHorizAxis.Horizontal := true;

for i:= 3 to 5 do begin
  (Chart1[i] as TBarSeries).StackGroup := 2;
  Chart1[i].CustomHorizAxis := CustomHorizAxis;
  Chart1[i].CustomVertAxis := CustomVertAxis;
  (Chart1[i] as tbarSeries).OffsetPercent := -50;
end;
with Chart1.Axes.Left do
begin
  StartPosition := 0;
  EndPosition := 50;
end;
with CustomVertAxis do
begin
  Visible := true;
  StartPosition := 60;
  EndPosition := 100;
  PositionPercent := 0;
end;
Chart1.axes.bottom.PositionPercent := 50;
end;

Post Reply