Aligning 2 charts' Y axis
Posted: Mon Apr 11, 2005 11:31 pm
Hi,
Here's another one. I have two charts on a form. I need to have their Y axis aligned exactly. The problem is the captions on the Y AXIS are different widths - typically the top charts values are in the 1000s and the bottom ones are single digits. The widths of the labels seems to be throwing off the positions of the Y Axis. Following code illustrates this (3D set false at design time).
chrtTop: TChart;
chrtBott: TChart;
SeriesTop: TBarSeries;
SeriesBott: TBarSeries;
// ....
self.chrtTop.Left := 0;
self.chrtTop.Width := 300;
self.chrtTop.Height := self.Height div 2;
self.SeriesTop.AddXY(1, 10000);
self.chrtBott.left := 0;
self.chrtBott.Top := (self.Height div 2) + 1;
self.chrtBott.Width := 300;
self.chrtBott.Height := self.Height div 2;
self.SeriesBott.AddXY(1, 1);
self.chrtBott.LeftAxis.LabelsSize :=
self.chrtTop.LeftAxis.LabelWidth(self.SeriesTop.MaxYValue );
Setting the bottom chart's leftAxis.LabelsSize helps, but it's still off by a few pixels. Is there something else I need to take into account?
Sample project available,
Thnks,
Rick
Here's another one. I have two charts on a form. I need to have their Y axis aligned exactly. The problem is the captions on the Y AXIS are different widths - typically the top charts values are in the 1000s and the bottom ones are single digits. The widths of the labels seems to be throwing off the positions of the Y Axis. Following code illustrates this (3D set false at design time).
chrtTop: TChart;
chrtBott: TChart;
SeriesTop: TBarSeries;
SeriesBott: TBarSeries;
// ....
self.chrtTop.Left := 0;
self.chrtTop.Width := 300;
self.chrtTop.Height := self.Height div 2;
self.SeriesTop.AddXY(1, 10000);
self.chrtBott.left := 0;
self.chrtBott.Top := (self.Height div 2) + 1;
self.chrtBott.Width := 300;
self.chrtBott.Height := self.Height div 2;
self.SeriesBott.AddXY(1, 1);
self.chrtBott.LeftAxis.LabelsSize :=
self.chrtTop.LeftAxis.LabelWidth(self.SeriesTop.MaxYValue );
Setting the bottom chart's leftAxis.LabelsSize helps, but it's still off by a few pixels. Is there something else I need to take into account?
Sample project available,
Thnks,
Rick