I have a chart on which there are say 8 series plotted, Series1, Series2,.....
Now I would like to mouseclick somewhere on the chart (not necessarily directly on a plotted series line), and automatically get the X value of say Series1.
Mike
Sensing series values
-
- Newbie
- Posts: 13
- Joined: Mon Jan 24, 2005 5:00 am
- Location: Oxford
- Contact:
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Mike,
You could do something as in the example suggested here. Instead of the cursor tool event you could use the OnMouseDown event to retrieve the clicked XValue like this:
You could do something as in the example suggested here. Instead of the cursor tool event you could use the OnMouseDown event to retrieve the clicked XValue like this:
Code: Select all
procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
XVal: double;
begin
XVal:=Chart1.Axes.Bottom.CalcPosPoint(X);
//Add the interpolating code here.
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 |
-
- Newbie
- Posts: 13
- Joined: Mon Jan 24, 2005 5:00 am
- Location: Oxford
- Contact:
Sensing series
Thanks, that partially solves my problem, which I realise I hadnt explained properly. A series consists of a list of X,Y values, numbered from 1 to a max number of items. So what I would like to so is to click anywhere on the chart, and then return the item value from one of the series, say Series1, rather than the actual X value.
regards
Mike
regards
Mike
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Mike,
In that case and if I understood your request correctly you can do something like this:
In that case and if I understood your request correctly you can do something like this:
Code: Select all
procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
XVal: double;
i, SeriesIndex: Integer;
begin
for i:=Chart1.ChartRect.Top to Chart1.ChartRect.Bottom do
begin
SeriesIndex:=Chart1[0].Clicked(X, i);
if SeriesIndex<>-1 then
begin
Chart1.Title.Text[0]:=FloatToStr(Chart1[0].XValue[SeriesIndex]) + ' - ' +
FloatToStr(Chart1[0].YValue[SeriesIndex]);
break;
end;
end;
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 |
-
- Newbie
- Posts: 13
- Joined: Mon Jan 24, 2005 5:00 am
- Location: Oxford
- Contact:
sensing series
Thanks. That does it. Very clever! I didnt know about an instruction like
SeriesIndex:=Chart[0].Clicked(X, i);
all the best
Mike
SeriesIndex:=Chart[0].Clicked(X, i);
all the best
Mike
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Mike,
You're very welcome. I'm glad to hear that helped.
Yes, Clicked method is very useful and is available for several TeeChart objects (series, axes, legend, ...).
Have a nice weekend!
You're very welcome. I'm glad to hear that helped.
Yes, Clicked method is very useful and is available for several TeeChart objects (series, axes, legend, ...).
Have a nice weekend!
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 |