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
Histogram BottomAxis issue
Hi Rick,
to do this you can use the following code :
to do this you can use the following code :
Code: Select all
Chart2.Axes.Bottom.SetMinMax(Chart1.Axes.Bottom.Minimum,Chart1.Axes.bottom.Maximum);
Chart2.Axes.Bottom.Increment := Chart1.Axes.Bottom.Increment;
Chart2.Axes.Bottom.MinimumOffset := 50;
Chart2.Axes.Bottom.MaximumOffset := 50;
Pep Jorge
http://support.steema.com
http://support.steema.com
Hi Pep,
This doesn't work, I;'m afraid. In the example I just tried it on, the histogram bottom axies goes from 0 to 835, let's say, but when the code at the top graphcs bottom axis maximum it is 758. This top chat is the histogram - it appears to return the maximum as the start of the last bin.
Also, increment is always zero. Shall I post a sample project to look at?
Regards,
Rick
This doesn't work, I;'m afraid. In the example I just tried it on, the histogram bottom axies goes from 0 to 835, let's say, but when the code at the top graphcs bottom axis maximum it is 758. This top chat is the histogram - it appears to return the maximum as the start of the last bin.
Also, increment is always zero. Shall I post a sample project to look at?
Regards,
Rick
Hi,
I've narrowed this down. It appears that witha histogram, the bottomAxis.maximum always returns the value of last bin, not the highest value on the axis. Self contained code below shows this, I think:
self.SeriesHist.Clear;
self.chrtHistogram.BottomAxis.Automatic := false;
self.chrtHistogram.BottomAxis.AutomaticMinimum := false;
self.chrtHistogram.BottomAxis.Minimum := 0;
self.chrHistogram.BottomAxis.AutomaticMaximum := true;
self.SeriesHist.AddXY(10, 1);
self.SeriesHist.AddXY(20, 1);
self.SeriesHist.AddXY(30, 1);
self.SeriesHist.AddXY(40, 1);
self.SeriesHist.AddXY(43, 1);
self.chrHistogram.update;
// It draws the bottom axis from 0 to 47
// but bottomAxis.maximum always returns 43 - the value of the hightest bin
showMessage( FloatToStr(self.chrHistogram.BottomAxis.Maximum)); // Always 43
ShowMessage( FloatToStr(self.chrHistogram.BottomAxis.Increment )); // Always 0
So what to do? Let me know if u want a project, but the above is all you need.
Regards,
Rick
I've narrowed this down. It appears that witha histogram, the bottomAxis.maximum always returns the value of last bin, not the highest value on the axis. Self contained code below shows this, I think:
self.SeriesHist.Clear;
self.chrtHistogram.BottomAxis.Automatic := false;
self.chrtHistogram.BottomAxis.AutomaticMinimum := false;
self.chrtHistogram.BottomAxis.Minimum := 0;
self.chrHistogram.BottomAxis.AutomaticMaximum := true;
self.SeriesHist.AddXY(10, 1);
self.SeriesHist.AddXY(20, 1);
self.SeriesHist.AddXY(30, 1);
self.SeriesHist.AddXY(40, 1);
self.SeriesHist.AddXY(43, 1);
self.chrHistogram.update;
// It draws the bottom axis from 0 to 47
// but bottomAxis.maximum always returns 43 - the value of the hightest bin
showMessage( FloatToStr(self.chrHistogram.BottomAxis.Maximum)); // Always 43
ShowMessage( FloatToStr(self.chrHistogram.BottomAxis.Increment )); // Always 0
So what to do? Let me know if u want a project, but the above is all you need.
Regards,
Rick