Get number of shown points lazarus / 55-TAChart ---------------------------------------------------------------------- fpcoder · 2017-02-03 21:45 Lets say 500 days of data is loaded into a TChartSourceList. A TLineSeries is showing this data on the chart. If zooming in, how to know how many days, or points, are now being plotted? Also, how to tell the series or chart to show only 200 days/points instead of all 500? ---------------------------------------------------------------------- wp · 2017-02-03 22:17 Quote from: kapibara on February 03, 2017, 10:45:55 pmLets say 500 days of data is loaded into a TChartSourceList. A TLineSeries is showing this data on the chart. If zooming in, how to know how many days, or points, are now being plotted?I guess you must count them. Call Chart.LogicalExtent to get the visible axis range (let's name it "ext"); the x axis starts at ext.a.x and ends at ext.b.x. Then you iterate through all data points and increment a counter if the x value of a data point is between ext.a.x and ext.b.x 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 uses  Math;var  ext: TDoubleRect;  i: Integer;  count: Integer;begin  count := 0;  ext := Chart1.LogicalExtent;  for i:=0 to Chart1LineSeries1.Count-1 do    if InRange(Chart1LineSeries1.XValue[i], ext.a.x, ext.b.x) then inc(count);end; Quote from: kapibara on February 03, 2017, 10:45:55 pmAlso, how to tell the series or chart to show only 200 days/points instead of all 500? Also by code. Declare a variable ext: TDoubleRect. Then decide at which data point index the 200 data points should start. Write its x value in ext.a.x. Then add 199 (= 200-1) to the index, get the x value of this data point and write it to ext.b.x. If you want the y axis to scale to the new data range you must iterate through all data points between the first and last index of the zoomed range and find the minimum and maximum of the data y values. The minimum goes to ext.a.y, the maximum to ext.b.y. Finally assign the Chart1.Logicalextent to ext. 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 uses  math;var  istart, iend: Integer;  ext: TDoubleRect;begin    istart := ....  // index of left-most datapoint  iend := istart + 199;  // Make sure to stay inside the data range  if iend >= Chart1LineSeries1.Count then begin    iend := chart1LineSeries1.Count - 1;    istart := iend - 199;  end;  ext.a.x := Chart1LineSeries1.XValue[istart];  ext.b.x := Chart1LineSeries1.XValue[iend];  ext.a.y := 1E308;  ext.b.y := -1E308;  for i:= istart to iend do begin    ext.a.y := Min(ext.a.y, Chart1LineSeries1.YValue[i]);    ext.b.y := Max(ext.b.y, Chart1LineSeries1.YValue[i]);  end;  Chart1.LogicalExtent := ext;end; NOTE: I assume that the chartsource of the lineseries is sorted (by x). And I assume that no axis transformations are involved. ---------------------------------------------------------------------- fpcoder · 2017-02-04 06:37 That immediately worked. :-) I'll try it out some more when I'm back in later today.