Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 2092

Summary: Clicked function returns hidden Marks if they were previously shown
Product: VCL TeeChart Reporter: yeray alonso <yeray>
Component: SeriesAssignee: Steema Issue Manager <issuemanager>
Status: RESOLVED FIXED    
Severity: enhancement    
Priority: ---    
Version: 25.180808   
Target Milestone: ---   
Hardware: PC   
OS: Windows   
URL: https://stackoverflow.com/questions/52461216/teechart-calcclickedpart-bug-after-marks-itemnpoint-visible-false
Chart Series: Line Delphi / C++ Builder RAD IDE Version:

Description yeray alonso 2018-09-24 04:02:31 EDT
As the customer reports at StackOverflow, sometimes marks individually hidden are still considered at CalcClickedPart.

The problem is actually at the TSeriesMarks.Clicked function, that doesn't consider the Items Visibility. So, if a Mark is ever drawn, its position and shape are defined and that's what is verified at that Clicked function, even if it has been hidden.

A simple example:

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.View3D:=false;
  Chart1.Legend.Hide;

  with Chart1.AddSeries(TLineSeries) as TLineSeries do
  begin
    for i:=0 to 8 do
    begin
      AddXY(i, 10);
      Marks.Item[i].Visible:=i<6;
    end;

    Marks.Show;
    Chart1.Draw;

    for i:=3 to Count-1 do
      Marks.Item[i].Hide;
  end;
end;


procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var ValueIndex: Integer;
begin
  Caption:='';

  ValueIndex:=Chart1[0].Marks.Clicked(X,Y);
  if ValueIndex>-1 then
  begin
    if Chart1[0].Marks[ValueIndex].Visible then
      Caption:='Mark'
    else
      Caption:='HIDDEN mark';

    Caption:=Caption + ' clicked at index ' + IntToStr(ValueIndex);
  end;
end;