Extents, simple use of lazarus / 55-TAChart ---------------------------------------------------------------------- mtanner · 2015-11-05 11:26 I'm  trying to use Extents in what I think is a fairly simple way. Looking at the documentation Extents seem to provide sophisticated control of multiple charts if required, but I'm just attempting simple control of a single chart. My application draws a chart with a function called DrawGraph; I want the user to choose whether to allow TAGraph to decide the Y-range to plot, or whether to specify the range themselves. Through GUI fields, the user sets the value of the following variables. AutoSw:boolean;   True if TAgraph is to decide Y-range, False if user values to be used. MyYLow,MyYHigh:double; User-specified values for the range. Testing as follows, manipulating the values through the GUI.. (1) AutoSw set to True; Graph drawn as expected. (2) AutoSw set to False; Graph drawn as expected, taking account of MyYLow,MyYHigh. (3) AutoSw set back to True. Graph still drawn using MyYLow, MyLowHigh. The code I use is as follows. Within DrawGraph var Extent:TDoubleRect; ...draw several series; If not AutoSw then begin               MyChart.Prepare;  { this seems to make no difference }               Extent:=MyChart.GetFullExtent;               Extent.A.Y:=MyYLow;               Extent.B.Y:=MyYHigh;               MyChart.Extent.FixTo(Extent);         end; What am I doing wrong? I originally thought I should use Range.UseMin etc. but that didn't work. I'm puzzled about the relationship between Range and Extent. ---------------------------------------------------------------------- mtanner · 2015-11-05 13:05 Well I've got an alternative bit of code that works, but it's unsatisfactory to not understand why. With MyChart.Extent do begin    YMin:=MyYmin;    YMax:=MyYmax;    UseYMin:=not AutoSw;    UseYMax:=not AutoSw; end; ---------------------------------------------------------------------- wp · 2015-11-05 15:27 Your "DrawGraph" procedure misses handling of the case AutoSw = true - just add "MyChart.UseYMin := false; MyChart.UseYMax := false;" to the "else" branch of the "if" statement: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i If not AutoSw then begin  //MyChart.Prepare;  { this seems to make no difference }  // only needed if called very "early"  Extent:=MyChart.GetFullExtent;  Extent.A.Y:=MyYLow;  Extent.B.Y:=MyYHigh;  MyChart.Extent.FixTo(Extent);end elsebegin  MyChart.UseYMin := false;  MyChart.UseYMax := false;end; This is practically the same code that you show in the second post. "Chart.FixTo(extent)" copies the elements of the DoubleRect to the Chart.Extent and sets the corresponding UseXXX parameters to true. The main reason for using FixTo is that setting the extent limits limits one by one is that this may occasionally crash if the maximum happens to be smaller than the miniumum: Suppose the chart contains two curves, the first one covering the range between -10 and -5, the second one between 5 and 10. --> the chart's extent is reported to range between -10 and 10. Then you zoom in to fully display the first curve --> the chart extent is now -10 ... -5. Now you want to zoom differently to fully expand the second curve: At first you set the Minimum value of this curve: 5. At this very moment the minimum of the chart (5) is greater than the maximum (-5). TAChart will create an exception for this case. If, on the other hand, you use FixTo, the axis limits are set without intermediately checking the order of the values, and the exception does not happen. As for the difference between Axis.Range and Chart.Extent you should maybe read the answer of Alexander S. Klenin ("Ask"), the original author of TAChart, to a similar question that I once posted: http://forum.lazarus.freepascal.org/index.php/topic,18323. The first impression is that both should have the same effect. But the Axis.Range plays a role in combining several axes in a paned chart, and in the definition of ranges for calculation of function series. In these cases, the ranges are combined by a logical union. Due to the union operation, ranges can only grow, never shrink. So, if you have data between -1 and 1 and set the axis range to -10 ... 10 this will work in the first place because the range grows. But if you later want to shrink the range to -2 to 2 the chart will not follow, it will stick to -10..10. If, on the other hand, you change the ranges by the Chart.Extent method, then the axes will change as expected (unless you mix up both methods - you should not do this) because the Chart.Extent overrides the internal range calculation (see point #4 in Ask's answer).