Delphi 10.1 Pro, VCL with embedded Teechart controls. CalcClickedPart shows cpSeriesMarks after a Marks set to be hidden at the place it was previously shown.
I may not deleting Marks correctly, only hiding it, or there is a bug in CalcClickedPart. Please advice.
I added a tLabel on the top-left which show the CalcClickedPart Part result. Also a button to toggle the Marks visibility.
The series & Marks creation:
procedure TForm2.FormCreate(Sender: TObject);
var i: Integer;
begin
Chart1.View3D:=false;
with Chart1.AddSeries(TLineSeries) as TLineSeries do
begin
for i := 0 to 9 do
begin
AddXY(i, 10);
Marks.Item[i].Visible := false; // Hide all Marks
end;
Marks.Show; // A global Marks enabled.
Marks.Item[5].Visible := true;
end;
end;
CalcClickedPart test:
procedure TForm2.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
Var
ClickedPart: tChartClickedPart;
sCursorText: string;
begin
sCursorText := '';
Chart1.CalcClickedPart(Point(X, Y), ClickedPart); // Return information about the TeeChart component below the Mouse pointer at an X,Y location.
Case ClickedPart.Part of
cpNone : sCursorText := 'cpNone';
cpLegend : sCursorText := 'cpLegend';
cpAxis : sCursorText := 'cpAxis';
cpSeries : sCursorText := 'cpSeries';
cpTitle : sCursorText := 'cpTitle';
cpFoot : sCursorText := 'cpFoot';
cpChartRect : sCursorText := 'cpChartRect';
cpSeriesMarks : sCursorText := 'cpSeriesMarks';
cpSeriesPointer : sCursorText := 'cpSeriesPointer ';
cpSubTitle : sCursorText := 'cpSubTitle';
cpSubFoot : sCursorText := 'cpSubFoot';
cpAxisTitle : sCursorText := 'cpAxisTitle';
end;
Label1.Caption := sCursorText;
end;
The Marks visibility toggling:
procedure TForm2.btnMarksToggleClick(Sender: TObject);
begin
with (Chart1[0] as tLineSeries).Marks.Item[5] do
Visible := not Visible;
end;
Marks is visible. A correct cpSeriesMarks (cursor in Red arrow):
Press the button to hide the Marks. Will get the following wrong CalcClickedPart. Marks is NOT visible. An incorrect cpSeriesMarks (cursor in Red arrow):
Do you have any idea for work around?
p.s I previously found a bug with CalcClickedPart when CalcVisiblePoints := false. This is another issue, not related to CalcVisiblePoints at all.
Thanks Reron
I've been able to reproduce the problem here so I've added it to the public tracker (#2092).
Note the problem is at TSeriesMarks.Clicked
function.
I've already fixed it for the next versions.
As a workaround, you could set Positions.Item[5]:=nil
:
procedure TForm2.btnMarksToggleClick(Sender: TObject);
const aMarksIndex = 5;
begin
with (Chart1[0] as tLineSeries).Marks do
begin
with Item[aMarksIndex] do
Visible := not Visible;
if not Item[aMarksIndex].Visible then
Positions.Items[aMarksIndex]:=nil;
end;
end;