TChartSeries.CalcFirstLastVisibleIndex not quite as expected

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Posts: 29
Joined: Wed Sep 02, 2015 12:00 am

TChartSeries.CalcFirstLastVisibleIndex not quite as expected

Post by Toreba » Mon Oct 26, 2015 11:33 am


I am using TeeChart Pro 2013.09.131119 32-bit VCL in Delphi XE5.

I have a series of three points plotted against a date-time x-axis. I set the x-axis extents such that the axis minimum has the same x-value as the first point, and the axis maximum has the same x-value as the last point. I run TChart.Refresh, then TChartSeries.CalcFirstLastVisibleIndex.

I then find that TChartSeries.FirstValueIndex = 0 and TChartSeries.LastValueIndex = 0.

And yet two points are visible (and three should be).

What am I doing wrong?



Site Admin
Site Admin
Posts: 8912
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Re: TChartSeries.CalcFirstLastVisibleIndex not quite as expected

Post by Yeray » Fri Oct 30, 2015 10:58 am

Hello Toreba,

I've given a try to the code below with the latest version and it seems to work fine for me after forcing a chart repaint with Chart1.Draw:

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
var Series1: TChartSeries;
    x0, x1: Integer;




  Caption:='FirstValueIndex: ' + IntToStr(x0) + ', LastValueIndex: ' + IntToStr(x1);
  Chart1.Axes.Bottom.SetMinMax(Series1.XValue[x0], Series1.XValue[x1]);
If you still find problems with it, could you please arrange a simple example project we can run as-is to reproduce the problem here?
Thanks in advance.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Posts: 1
Joined: Fri Sep 18, 2020 12:00 am

Re: TChartSeries.CalcFirstLastVisibleIndex not quite as expected

Post by toreba » Thu Sep 24, 2020 11:06 am


Returning to this post from five years ago, I never had time to pursue the problem, but I need to now. The issue seems to persist today with TeeChart Pro v2019.27.190530 32bit VCL in Delphi 10.3 Version 26.0.33219.4899. Not sure that it has been dealt with in any other posts on this forum. The attached project shows what happens.

I fill an inverted, stair-mode TFastLineSeries on a date-time horizontal axis with 1000 random points. The series is displayed.

I call CalcFirstLastVisibleIndex. The series' VisibleCount property is then zero, as are its FirstDisplayedIndex, LastDisplayedIndex, FirstValueIndex and LastValueIndex. That's wrong for a start.

I zoom in using the mouse, call CalcFirstLastVisibleIndex in the OnZoom event. Then the series reports 1000 displayed points, first and last indices 0 and 999. So, wrong again, one step behind.

I zoom out using the mouse, call CalcFirstLastVisibleIndex in the OnUndoZoom event. The series now reports 529 displayed points, between indices 80 and 608. Again, wrong and one step behind.

Calling CalcFirstLastVisibleIndex twice doesn't help.

So, clearly I misunderstand the meaning of this method and these properties. How do I get the series to tell me how many points it has displayed?

And what is the difference between FirstDisplayedIndex and FirstValueIndex? When are they ever different?


2. Zoom In.gif
2. Zoom In.gif (35.44 KiB) Viewed 34 times
3. Zoom Extents.gif
3. Zoom Extents.gif (38.04 KiB) Viewed 34 times
(54.32 KiB) Downloaded 1 time

Post Reply