Following code results in 2 bins of different widths. Shouldn't bins always be the same width? How to make them so?
Regards,
Rick
type
TForm1 = class(TForm)
Button1: TButton;
Chart1: TChart;
Series1: THistogramSeries;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
self.Series1.Clear;
self.Chart1.BottomAxis.AutomaticMinimum := false;
self.Chart1.BottomAxis.Minimum := 0;
self.Chart1.LeftAxis.AutomaticMinimum := false;
self.Series1.AddXY(100, 2);
self.Series1.AddXY(500, 4);
end;
HistoGram Bin Width
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Rick,
Yes, the problem is in the axes settings. Using the code below works fine but the bins are different sized after scrolling the chart. If you uncomment the commented line then also works fine after scrolling.
Also notice that I've included this scrolling issue into our defect list to be fixed for future releases.
Yes, the problem is in the axes settings. Using the code below works fine but the bins are different sized after scrolling the chart. If you uncomment the commented line then also works fine after scrolling.
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
begin
self.Series1.Clear;
self.Chart1.LeftAxis.SetMinMax(0,6);
//self.Chart1.BottomAxis.SetMinMax(-100,700);
self.Series1.AddXY(100, 2);
self.Series1.AddXY(500, 4);
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi Narcis,
In that specific case that does seem to fix the issue, but in the general case, there are still problems with the bin widths being different if I set the axis min / max myself. My goal is simple. I have two histograms showing different data, but I want the bottom axis scales to be the same to illustrate the differences between the two data sets. My code is:
self.framSampStatsGraphs.chrtFrequency.BottomAxis.SetMinMax(
self.framPopStatsGraphs.chrtFrequency.BottomAxis.Minimum,
self.framPopStatsGraphs.chrtFrequency.BottomAxis.Maximum);
self.framSampStatsGraphs.chrtFrequency.Update;
The frequency chart in the Pop (population) has already been draw, and it uses automatic. I want the Samp (sample) frequency chart to have the same bottom axis. I have scrolling and zooming turned off at design time.
Regards,
Rick
In that specific case that does seem to fix the issue, but in the general case, there are still problems with the bin widths being different if I set the axis min / max myself. My goal is simple. I have two histograms showing different data, but I want the bottom axis scales to be the same to illustrate the differences between the two data sets. My code is:
self.framSampStatsGraphs.chrtFrequency.BottomAxis.SetMinMax(
self.framPopStatsGraphs.chrtFrequency.BottomAxis.Minimum,
self.framPopStatsGraphs.chrtFrequency.BottomAxis.Maximum);
self.framSampStatsGraphs.chrtFrequency.Update;
The frequency chart in the Pop (population) has already been draw, and it uses automatic. I want the Samp (sample) frequency chart to have the same bottom axis. I have scrolling and zooming turned off at design time.
Regards,
Rick
More Information on Histogram Bin Widths
The following code produces the first bin in series 1 as much wider thatn the other bins. Narcis' previous reply implied this had to do with scrolling -there is no scrolling or zooming on these charts.
There are two charts, and one histogram series in each chart. I'm really stuck on this.....
self.Chart2.LeftAxis.AutomaticMinimum := false;
self.Chart2.BottomAxis.AutomaticMinimum := false;
self.Series2.AddXY(10, 100);
self.Series2.AddXY(20, 200);
self.Series2.AddXY(30, 300);
self.Series2.AddXY(40, 400);
self.Series2.AddXY(50, 500);
self.Series2.AddXY(60, 600);
self.Chart2.Update;
self.Series1.Clear;
self.Chart1.LeftAxis.SetMinMax(0, 100);
self.Chart1.BottomAxis.SetMinMax( 0,
self.Chart2.BottomAxis.Maximum );
self.Series1.AddXY(1, 10);
self.Series1.AddXY(2, 20);
self.Series1.AddXY(3, 30);
self.Series1.AddXY(4, 40);
self.Series1.AddXY(5, 50);
self.Series1.AddXY(6, 60);
Regards,
Rick
The following code produces the first bin in series 1 as much wider thatn the other bins. Narcis' previous reply implied this had to do with scrolling -there is no scrolling or zooming on these charts.
There are two charts, and one histogram series in each chart. I'm really stuck on this.....
self.Chart2.LeftAxis.AutomaticMinimum := false;
self.Chart2.BottomAxis.AutomaticMinimum := false;
self.Series2.AddXY(10, 100);
self.Series2.AddXY(20, 200);
self.Series2.AddXY(30, 300);
self.Series2.AddXY(40, 400);
self.Series2.AddXY(50, 500);
self.Series2.AddXY(60, 600);
self.Chart2.Update;
self.Series1.Clear;
self.Chart1.LeftAxis.SetMinMax(0, 100);
self.Chart1.BottomAxis.SetMinMax( 0,
self.Chart2.BottomAxis.Maximum );
self.Series1.AddXY(1, 10);
self.Series1.AddXY(2, 20);
self.Series1.AddXY(3, 30);
self.Series1.AddXY(4, 40);
self.Series1.AddXY(5, 50);
self.Series1.AddXY(6, 60);
Regards,
Rick
Hi, Rick.
Yes, I get the same results. It's a bug in histogram series drawing algorithm. To be more precise, histogram bin width is not calculated correctly. We'll log this to the bug list and try to improve/fix it for next maintenance release.
In the meantime the best workaround is to use the approach Narcis recomended.
Yes, I get the same results. It's a bug in histogram series drawing algorithm. To be more precise, histogram bin width is not calculated correctly. We'll log this to the bug list and try to improve/fix it for next maintenance release.
In the meantime the best workaround is to use the approach Narcis recomended.
Marjan Slatinek,
http://www.steema.com
http://www.steema.com