Search code examples
delphiteechartdelphi-10.1-berlin

TeeChart How to force a Mark to behave the same as a Pointer?


Delphi 10.1, Windows 10 Pro x64, TeeChart pro 2017.20. For LineSeries chart with alot of points (1471 points), I would like to show a selective one Mark, defined in code. I can see the Mark only if I zoom the window enough. There are situations, with some partial zoom, the Mark is shown and hiden while dragging (PAN) the chart with right mouse (see pictures). Visible Mark Un visible mark, same resolution as previous, just moved (PAN)

On the other hand, a pointer is behave exactly as I want. I can always see it on ant zoom. Here is a short code with Marks and Pointers for demonstration:

procedure TForm1.FormCreate(Sender: TObject);
var
  Series: tLineSeries;
  i: integer;
begin
  // Chart settings
  Chart1.Align  := alClient;
  Chart1.View3D := false;

  // LineSeries definition
  Series:=Chart1.AddSeries(TLineSeries.Create(Self)) as tLineSeries;
  Series.FillSampleValues(1471);

  // Marks
  Series.Marks.Visible := true; // Global flag
  //Series.Marks.AutoPosition := false;
  //Series.Marks.Automatic.Move:= false;
  for i := 0 to Series.Count-1 do
    Series.Marks[i].Visible := false;
  Series.Marks[506].Visible := true;

  // Pointers
  Series.Pointer.Visible := true;  // Global flag
  for i := 0 to Series.Count-1 do
    Series.Pointer[i].Visible := false;
  Series.Pointer[506].Visible := true;
end;

How to force a Mark to behave the same as a Pointer?


Solution

  • TeeChart calculates the minimum "Draw Every" step, when there are more marks to display than available pixels. This optimization interferes with your setup.
    Try setting this to skip this optimization:

    Series.CalcVisiblePoints:=False;