Page 1 of 1
Question about stacked bar chart
Posted: Mon Mar 29, 2004 10:32 am
by 8578456
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.
Posted: Mon Mar 29, 2004 11:52 am
by Pep
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;