TCursorTool is not working on series with custom axes

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
PoLabs
Newbie
Newbie
Posts: 13
Joined: Tue Aug 04, 2015 12:00 am

TCursorTool is not working on series with custom axes

Post by PoLabs » Mon Jul 18, 2016 11:51 am

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.

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

Re: TCursorTool is not working on series with custom axes

Post by Yeray » Tue Jul 19, 2016 9:35 am

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;
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

Post Reply