Chart custom graphics drawing
Posted: Wed Jan 14, 2015 4:30 pm
Hi,
I am doing some custom drawing on my chart control in connection with mouse movements. In other words, whenever I move mouse I am drawing some graphics on my chart.
Right now I am handling chart's OnBeforeDrawSeries and OnMouseMove.
eg. (just an example to show my apporach):
At first look this method seems to be fine but it looks like it takes some time to preocess Chart.Repain and all custom graphics seems to be drawing quite slow. I checked out my methods and measured time to process and everythings looks reasonable (<1us).
I am not drawing on canvas directly in OnMouseMove event because graphics gets messed up if Chart.Repaint is called from any other method. Therefore I just execute Chart.Repaint to start events such as BeforeDrawSeries and AfterDrawGraph and do drawing there.
Is there any better approach to do that? What about declaring new class derived from Tchart and use some protected methods? Any suggestion?
Thank you in advance.
Kind regards.
I am doing some custom drawing on my chart control in connection with mouse movements. In other words, whenever I move mouse I am drawing some graphics on my chart.
Right now I am handling chart's OnBeforeDrawSeries and OnMouseMove.
eg. (just an example to show my apporach):
Code: Select all
procedure xxx.OnMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
LastPt.X := x;
LastPt.Y := y;
Chart.Repaint;
end;
procedure xxx.OnBeforeDrawSeries(Sender: TObject);
begin
Chart.Canvas.TextOut(LastPt.x, LastPt.Y, 'Some text');
end;
I am not drawing on canvas directly in OnMouseMove event because graphics gets messed up if Chart.Repaint is called from any other method. Therefore I just execute Chart.Repaint to start events such as BeforeDrawSeries and AfterDrawGraph and do drawing there.
Is there any better approach to do that? What about declaring new class derived from Tchart and use some protected methods? Any suggestion?
Thank you in advance.
Kind regards.