zoom problems?
Posted: Fri Jun 11, 2004 12:58 am
I've got a fairly simple chart displaying a TPointSeries. There are about 500 elements in this series, which is relatively small compared to what we might want to display. At the moment, I'm simply trying to get a form with a chart that has zooming on it. I added a spin button, a TLabel, and a TChartScrollBar to the form. The spinner's OnChange handler looks like this:
(This particular spinner supports a range from -10 to +10.) The idea is that when the value is < 0 then it's supposed to zoom "out", and when it's > 0 it's supposed to zoom "in" (or vice-versa). Each increment > 0 changes the zoom factor by 50%, while increments < 0 change it by 10%.
However, regardless of what the value of Z is set to in ZoomPercent, it always seems to SHRINK the display -- except when it's 150, and then it does something REALLY strange. (The description for ZoomPercent says simply that this factor is a percentage. No examples are provided that I could find.)
The values of Z are in the range [0.10, 0.20, ... 0.90, 1, 50, 100, 150, ... 500].
Also, we're only interested in Zooming along the X-axis, not the Y-axis. No matter what I set, this function always re-adjusts the Y-axis for any zoom setting other than the default. The data I'm working with has a very narrow range betwen 0 and 5, so setting the Y-axis to -100 ... +100 (which is what it does for unknown reasons) makes the "zoom in" useless because the dots make up a horizontal line! How the heck can I zoom the X-axis without having the Y-axis changed AT ALL?
Code: Select all
procedure TMProfiler_form.zoom_spinnerChange(Sender: TObject);
var z : double;
begin
ChartScrollBar1.Visible := zoom_spinner.Value <> 0;
if (zoom_spinner.Value < 0) then
z := ((10+zoom_spinner.Value)*10)/100
else if (zoom_spinner.Value = 0) then
z := 100 // if it's a percentage, then "no-zoom" should be 100 (?)
else
z := 100+((zoom_spinner.Value)*50);
Chart1.ZoomPercent(z);
zoom_lbl.Caption := Format('zoom pct = %2.2f%%',[z]);
Chart1.Zoomed := zoom_spinner.Value <> 0;
end;
However, regardless of what the value of Z is set to in ZoomPercent, it always seems to SHRINK the display -- except when it's 150, and then it does something REALLY strange. (The description for ZoomPercent says simply that this factor is a percentage. No examples are provided that I could find.)
The values of Z are in the range [0.10, 0.20, ... 0.90, 1, 50, 100, 150, ... 500].
Also, we're only interested in Zooming along the X-axis, not the Y-axis. No matter what I set, this function always re-adjusts the Y-axis for any zoom setting other than the default. The data I'm working with has a very narrow range betwen 0 and 5, so setting the Y-axis to -100 ... +100 (which is what it does for unknown reasons) makes the "zoom in" useless because the dots make up a horizontal line! How the heck can I zoom the X-axis without having the Y-axis changed AT ALL?