Is chart zoomed? lazarus / 55-TAChart ---------------------------------------------------------------------- wp · 2012-04-19 22:04 In order to determine whether a chart is zoomed or not, I need to compare Chart.GetFullExtent and Chart.LogicalExtent (-- or is there a better way?). The code would be more readable if there were a function or property "IsZoomed". TChart already uses an internal variable FIsZoomed. Could you make this a public read-only property? ---------------------------------------------------------------------- Ask · 2012-04-20 01:41 I can, but first I'd like to know why you need this. IsZoomed is an implementation detail which might change, so I want to avoid publishing it if possible. Meanwhile, you can use RenderingParams.FIsZoomed, which is also an internal detail, but (unfortunately) already published ---------------------------------------------------------------------- wp · 2012-04-20 06:52 QuoteI'd like to know why you need this The chart displays measured data coming in at given rate. When the chart is not zoomed the axes are updated with every new data arriving. When the chart is zoomed, however, the zoomed rectangle is retained. ---------------------------------------------------------------------- Ask · 2012-04-20 09:53 Is it similar to the "Oscilloscope" page of linedemo? ---------------------------------------------------------------------- wp · 2012-04-20 12:45 Not exactly. The oscilloscope demo adds a new point at the end and deletes the first point of the series. I just add the new point and do not delete the first point. In addition, the new x axis maximum (chart.Extent.XMax) is calculated to be a bit in advance to get a smoother appearence. Only when the current x series maximum exceeds the preset maximum axis rescaling is repeated. When the chart is zoomed, I just want to freeze updating the axes, e.g. to look at a feature of the curve in more detail. ---------------------------------------------------------------------- Ask · 2012-04-20 13:01 Sure, but that is a minor difference -- you can replace Code: [Select]if Count > 20 then   ListSource.Delete(0); by something like Code: [Select]chOscillator.Extent.XMax := (Count div 20 + 1) * 20; chOscillator.Extent.UseXMax := true; and get the behaviour you described. ---------------------------------------------------------------------- wp · 2012-04-20 16:23 That's exactly what I do. But the problem is that the zoomed view is lost whenever a new point is added -- see the attached demo. Strangely enough, this does not happen in the oscilloscope demo. To avoid this undesired behavior I query whether the chart is zoomed nor not (see the commented code in TForm1.AdjustExtent. And this brings me back to my initial posting: Could you provide a function or property "IsZoomed"? Code such as Code: [Select]if Chart.IsZoomed then   do_something: is definitely much clearer to understand than Code: [Select]if Chart.GetFullExtent = Chart.LogicalExtent then   do_something; ---------------------------------------------------------------------- Ask · 2012-04-21 14:06 QuoteBut the problem is that the zoomed view is lost whenever a new point is added -- see the attached demo. Strangely enough, this does not happen in the oscilloscope demo. Did you notice the usage of TChartRenderingParams and a comment in timOscilloscopeTimer procedure? Those are the main reason I pointed out this demo. Anyway, the change you ask is a one-liner, so I just went ahead and made it in r36955. I am just reluctant to deal with backwards compatibility issues if IsZoomed will be removed as a concept. ---------------------------------------------------------------------- wp · 2012-04-21 20:20 Thank you. I understand now. Quote...if IsZoomed will be removed as a concept Are you planning to remove zooming? ---------------------------------------------------------------------- Ask · 2012-04-22 06:22 Quote from: wp on April 21, 2012, 10:20:36 pmAre you planning to remove zooming? Of course no, just the 'FIsZoomed' variable. I have a feeling that the default zoom level should not be so specific as to require a separate variable. OTOH, I can always re-implement the property as Result := GetFullExtent = LogicalExtent to preserve compatibility, so that is probably ok.