Add value on mouse pos
Add value on mouse pos
When I click on the chart I want to add a value on this position. How can I calculate the chart x/y position from the mouse position?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi CT,
You can do that using TChart's OnMouseDown event:
You can do that using TChart's OnMouseDown event:
Code: Select all
procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var xval, yval: Double;
begin
xval:=Series1.XScreenToValue(X);
yval:=Series1.YScreenToValue(Y);
Series1.AddXY(xval,yval);
end;
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 |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi CT,
This is because to get it working you need to already have some values on the series as done here:
Other alternatives would be using a TDrawLineTool or custom drawing on TChart's canvas.
For more information on TChart tools please have a look at the features demo at the TeeChart program group. For information on how to custom draw on the canvas, have a look at the tutorials at the TeeChart "Docs" folder and on the features demo as well.
This is because to get it working you need to already have some values on the series as done here:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues(2);
end;
procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var xval, yval: Double;
begin
xval:=Series1.XScreenToValue(X);
yval:=Series1.YScreenToValue(Y);
Series1.AddXY(xval,yval);
end;
For more information on TChart tools please have a look at the features demo at the TeeChart program group. For information on how to custom draw on the canvas, have a look at the tutorials at the TeeChart "Docs" folder and on the features demo as well.
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 |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi CT,
It's ok for us if it's ok for your needs. However if you want us to look further at it please send us an example we can run "as-is" to reproduce the problem here spceifying wich TeeChart version you are using.
You can post your files at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup.
It's ok for us if it's ok for your needs. However if you want us to look further at it please send us an example we can run "as-is" to reproduce the problem here spceifying wich TeeChart version you are using.
You can post your files at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup.
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 |