Drawing on Chart
Drawing on Chart
I would like to enable a user too highlight a part of a graph by draw a box or circle around a section of the chart. I have tried to use the rectangle tool but at runtime the only effect I get is to in act the zoom feature. If the rectangle is the right tool then how do I enable it? I have also tried the annotation tool but I can not enact it.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi McMClark,
I've just replied to the thread you posted in the ActiveX forum:
http://www.teechart.net/support/viewtop ... 1566#31566
Same idea applies to the VCL version.
I've just replied to the thread you posted in the ActiveX forum:
http://www.teechart.net/support/viewtop ... 1566#31566
Same idea applies to the VCL version.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi McMClark,
One solution could be drawing a Shape series instead of a canvas rectangle in OnMouseUp event:
One solution could be drawing a Shape series instead of a canvas rectangle in OnMouseUp event:
Code: Select all
var
Form1: TForm1;
X0, X1, Y0, Y1: Integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
X0 := -1;
Y0 := -1;
Chart1.Zoom.Allow := false;
Chart1.View3D := false;
end;
procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
X1 := X;
Y1 := Y;
If (X0 <> -1) And (Y0 <> -1) Then
begin
Chart1.Canvas.Brush.Style := bsClear;
Chart1.Canvas.Pen.Color := clBlack;
Chart1.Canvas.Rectangle(X0, Y0, X1, Y1);
Chart1.Draw;
End;
end;
procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
X0 := X;
Y0 := Y;
end;
procedure TForm1.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var RectSeries: TChartShape;
begin
If (X0 <> -1) And (Y0 <> -1) Then
begin
RectSeries := TChartShape.Create(Self);
Chart1.AddSeries(RectSeries);
with (Chart1.Axes) do
begin
RectSeries.Style := chasRectangle;
RectSeries.X0 := Bottom.CalcPosPoint(X0);
RectSeries.Y0 := Left.CalcPosPoint(Y0);
RectSeries.X1 := Bottom.CalcPosPoint(X1);
RectSeries.Y1 := Left.CalcPosPoint(Y1);
end;
End;
X0 := -1;
Y0 := -1;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Alexander,
No, using OnAfterDraw event is a good option for custom drawing on the chart.
No, using OnAfterDraw event is a good option for custom drawing on the chart.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |