Lazarus

Programming => Graphics and Multimedia => TAChart => Topic started by: wp on August 20, 2011, 10:59:12 pm

Title: DatapointCrosshairTool issues for two charts sharing the same ChartToolset
Post by: wp on August 20, 2011, 10:59:12 pm
The attached little demo project contains two charts that share the same ChartToolset. The ChartToolset contains a ZoomDragTool activated by the left mouse button and a DatapointCrosshairTool activated by the right mouse button. While the ZoomDragTools works as expected there is an issue with the DatapointCrosshairTool:

- Run the project
- Right-drag in the left chart --> the crosshair appears
- Note that the crosshairs do not disappear at mouse-up although this behavior is implemented in the corresponding event.
- Now right-drag the mouse in the right chart --> no cross-hairs
- Left-drag in the right chart to zoom, and immediately afterwards left-click to unzoom
- Right-drag in the right chart --> now the cross-hair appears
- Again, the crosshairs does not disappear upon mouse-up.
- The same happens if you right-drag in the left chart again.

It should be mentioned also that the crosshairs seem to work only with TLineSeries, not with TFuncSeries that I used in this demo initially.
Title: Re: DatapointCrosshairTool issues for two charts sharing the same ChartToolset
Post by: madepabloh on August 20, 2011, 11:50:21 pm
Nice idea wp,

However i can not compile it. It returns this error:
Quote
unit1.pas(21,66) Error: Identifier not found "TDataPointCrosshairTool"

is it my problem or other people had similar problem?

Thanks!
Title: Re: DatapointCrosshairTool issues for two charts sharing the same ChartToolset
Post by: wp on August 20, 2011, 11:57:10 pm
The DatapointCrosshairTool has been added by ask to the package only recently, you need to use the current svn version.
Title: Re: DatapointCrosshairTool issues for two charts sharing the same ChartToolset
Post by: madepabloh on August 21, 2011, 01:05:13 am
Where could i locate it? I do not see that information anywhere... thanks!
Title: Re: DatapointCrosshairTool issues for two charts sharing the same ChartToolset
Post by: Ask on August 21, 2011, 07:09:04 am
http://wiki.lazarus.freepascal.org/Getting_Lazarus (http://wiki.lazarus.freepascal.org/Getting_Lazarus)
Title: Re: DatapointCrosshairTool issues for two charts sharing the same ChartToolset
Post by: Ask on August 21, 2011, 11:28:02 am
- Note that the crosshairs do not disappear at mouse-up although this behavior is implemented in the corresponding event.

Fixed in r32024

- Now right-drag the mouse in the right chart --> no cross-hairs
- Left-drag in the right chart to zoom, and immediately afterwards left-click to unzoom
- Right-drag in the right chart --> now the cross-hair appears
The problem is that the tool only stores a single local state (in this case, Position),
but it should generally store a separate state for each chart it is used on.
I actually plan to implement this, but do not have time right now.
Added workaround in r32025 which fixes the issues you mentioned.
(But does not fix some other problems -- for example, if you minimize the application
while holding right mouse button, then restore it, crosshair will be drawn on both charts).
Hopefully the workaround will suffice until the full solution arrives.

It should be mentioned also that the crosshairs seem to work only with TLineSeries, not with TFuncSeries that I used in this demo initially.
This is because finding nearest point of the function graph requires full recalculation of the function,
which I avoided on performance grounds.
In r32026 I have added a compromise solution -- it just takes the point with the same X as the cursor,
and declares it the nearest one.
What do you think -- is it enough?
Title: Re: DatapointCrosshairTool issues for two charts sharing the same ChartToolset
Post by: wp on August 21, 2011, 11:45:19 am
Quote
I actually plan to implement this, but do not have time right now.
Don't hurry...

Quote
It just takes the point with the same X as the cursor,
and declares it the nearest one.
Maybe you should scan at least the step interval.
Title: Re: DatapointCrosshairTool issues for two charts sharing the same ChartToolset
Post by: wp on August 22, 2011, 03:14:57 pm
Mouse-up is now handled correctly. Also changing from one chart to the other works much better now.
Title: Re: DatapointCrosshairTool issues for two charts sharing the same ChartToolset
Post by: Ask on August 28, 2011, 09:54:33 am
Quote
It just takes the point with the same X as the cursor,
and declares it the nearest one.
Maybe you should scan at least the step interval.

Since r32075 points inside GrabRaduis are considered.
Title: Re: DatapointCrosshairTool issues for two charts sharing the same ChartToolset
Post by: wp on October 15, 2011, 12:16:28 pm
I've got to bring up this old thread again, since the issue mentioned in the beginning occurs similarly for the new ZoomMouseWheelTool: Zooming by means of the mouse wheel works only in one of the two charts. Only when the second chart is zoomed by means of an additional ZoomDragTool zooming by mouse wheel works in this chart, however, no longer in the first chart. I tried to SetFocus in the OnBeforeMouseWheel events, but this event is not triggered for the other chart.

The same holds for the PanDragTool.

See the attached demo.
Title: Re: DatapointCrosshairTool issues for two charts sharing the same ChartToolset
Post by: Ask on October 16, 2011, 09:09:45 am
Should be fixed in r32917
Title: Re: DatapointCrosshairTool issues for two charts sharing the same ChartToolset
Post by: wp on October 16, 2011, 10:21:39 am
Thank you. Perfect!