Page 1 of 1

TCursorTool is not working on series with custom axes

Posted: Mon Jul 18, 2016 11:51 am
by 16575142
Hi,

I have a problem using TCursorTool. I have a series with custom bottom and left axes.

CursorSeries.CustomHorizAxis := MyBottomAxis;
CursorSeries.CustomVertAxis := MyLeftAxis;

and cursor tool is not working. I have sources of TeeChart and inspected why this is happening and I saw code:

Code: Select all

Function TTeeCustomToolSeries.GetHorizAxis:TChartAxis;
begin
  if Assigned(FSeries) then
     result:=FSeries.GetHorizAxis
  else
  with ParentChart do
  begin
    if HasActiveSeries(BottomAxis) then
       result:=BottomAxis
    else
    if HasActiveSeries(TopAxis) then
       result:=TopAxis
    else
       result:=BottomAxis;
  end;
end;
I would add to check if assigned series has custom axis to use it... something like this:

Code: Select all

  if Assigned(FSeries) then
  begin
    if FSeries.HorizAxis = aCustomHorizAxis then
     Result := FSeries.CustomHorizAxis else
     Result:=FSeries.GetHorizAxis
  end else
  with ParentChart do
  begin
    if HasActiveSeries(BottomAxis) then
       result:=BottomAxis
    else
    if HasActiveSeries(TopAxis) then
       result:=TopAxis
    else
       result:=BottomAxis;
  end;
And same goes for vertical axis.

Re: TCursorTool is not working on series with custom axes

Posted: Tue Jul 19, 2016 9:35 am
by yeray
Hello,

I've been able to reproduce the issue, so I've created the according ticket here:
http://bugs.teechart.net/show_bug.cgi?id=1582

Thanks for reporting it.

I've also closed the ticket with the fix you've suggested, slightly modified:

Code: Select all

Function TTeeCustomToolSeries.GetHorizAxis:TChartAxis;
var i: Integer;
begin
  if Assigned(FSeries) then
  begin
    if FSeries.HorizAxis=aCustomHorizAxis then
       result:=FSeries.CustomHorizAxis
    else
       result:=FSeries.GetHorizAxis;
  end
  else
  with ParentChart do
  begin
    if HasActiveSeries(BottomAxis) then
       result:=BottomAxis
    else
    if HasActiveSeries(TopAxis) then
       result:=TopAxis
    else
    begin
      result:=BottomAxis;

      for i:=0 to ParentChart.CustomAxes.Count-1 do
        if ParentChart.CustomAxes[i].Horizontal and
           HasActiveSeries(ParentChart.CustomAxes[i]) then
        begin
          result:=ParentChart.CustomAxes[i];
          exit;
        end;
    end;
  end;
end;