Histogram BottomAxis issue
Posted: Fri Mar 18, 2005 2:29 am
Hi,
Another one for you guys. I have two charts in a panel - one aligned alTop, the othe alClient. The top chart is a histogram, the bottom chart a box plot. Two different views of the same data. I want the bottom Axis on the bottom chart - the box plot - to be the same as the bottom axis on the top chart - the histogram.
For the top chart, I leave all the axis things automatic, so T-Chart generates the min, max etc for me. If I leave the bottom chart Axis on automatic, because it is a box plot, the values are slightly different - in this case just the maximum value. So I try to set the bottom axis in code.
I have this:
// chrtBoxPlot is the bottom chart, chrtFreq the top one
With ChrtBoxPlot Do
begin
BottomAxis.AutomaticMaximum := false;
BottomAxis.AutomaticMinimum := false;
BottomAxis.Maximum := self.chrtFrequency.BottomAxis.Maximum;
BottomAxis.Minimum := self.chrtFrequency.BottomAxis.Minimum;
It almost works, except, the maximum value returned by the histogram appears to be the start position of the last bin. This is noticable if each bin takes 50 pixels or so - if each bin is say 5 pixles the error is still there, but you can't see it as easily.
Is this an error? I am trying to work around it by adding onto the maximum the width of a bin - which I thought would be given by:
BottomAxis.Maximum := self.chrtFrequency.BottomAxis.Maximum +
self.chrtFrequency.BottomAxis.Increment;
but in this case bottomAxis.increment is 0 - probably because I set it to auto. How can I determine the width of a histogram bin? Or is there an easier way to do what I am trying to do?
Regards,
Rick
Another one for you guys. I have two charts in a panel - one aligned alTop, the othe alClient. The top chart is a histogram, the bottom chart a box plot. Two different views of the same data. I want the bottom Axis on the bottom chart - the box plot - to be the same as the bottom axis on the top chart - the histogram.
For the top chart, I leave all the axis things automatic, so T-Chart generates the min, max etc for me. If I leave the bottom chart Axis on automatic, because it is a box plot, the values are slightly different - in this case just the maximum value. So I try to set the bottom axis in code.
I have this:
// chrtBoxPlot is the bottom chart, chrtFreq the top one
With ChrtBoxPlot Do
begin
BottomAxis.AutomaticMaximum := false;
BottomAxis.AutomaticMinimum := false;
BottomAxis.Maximum := self.chrtFrequency.BottomAxis.Maximum;
BottomAxis.Minimum := self.chrtFrequency.BottomAxis.Minimum;
It almost works, except, the maximum value returned by the histogram appears to be the start position of the last bin. This is noticable if each bin takes 50 pixels or so - if each bin is say 5 pixles the error is still there, but you can't see it as easily.
Is this an error? I am trying to work around it by adding onto the maximum the width of a bin - which I thought would be given by:
BottomAxis.Maximum := self.chrtFrequency.BottomAxis.Maximum +
self.chrtFrequency.BottomAxis.Increment;
but in this case bottomAxis.increment is 0 - probably because I set it to auto. How can I determine the width of a histogram bin? Or is there an easier way to do what I am trying to do?
Regards,
Rick