Get values from chart when clicked

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Command Alkon
Newbie
Newbie
Posts: 12
Joined: Thu Oct 28, 2004 4:00 am

Get values from chart when clicked

Post by Command Alkon » Tue Apr 12, 2005 11:08 pm

We are using Delphi 7.1, TeeChart 7 for the development.

We have many charts in the application and lately client wants us to implement a feature where they can click on the chart and that inturn will display a form or a hint which displays Label and Values and much more information about the state of few more variables in the application which is not a part of the chart.

Now when I have a chart displayed via program then I can click on Edit button for the chart which brings up an editing box. Now I got to "Tools" tab and click on Add button which brings up Chart Tools Gallery dialog box.

Select Mark Tip and press OK. Then select the "Series", "Label and Value", "Either click or mouse over" and "Delay"

Press OK on the main dialog box and then move the mouse on the chart or click on the point or a line connecting 2 points and it will display the label and values of axis as a tool tip.

I want to do the similar kind of thing but want to add more information to the tool tip which is displayed.

So my plan was to have some code in Chart's click event which finds if the point or the line was clicked and then get the values and pass those values back to the program with an event so the program can display a tool tip or format the values the way we want and display it differently.

If anyone has a small code sample to detect if the point or line was clicked and what were the Label and Value of each axis then I would apreciate it. I can manage the event part once I have all the values.

Cheers,

Nirav

P.S. : I would attach some images to explain more but there is no way to upload an image on this forum but I will try to upload it on a site and so it can be viewed.

Command Alkon
Newbie
Newbie
Posts: 12
Joined: Thu Oct 28, 2004 4:00 am

Post by Command Alkon » Tue Apr 12, 2005 11:14 pm

OK I have uploaded 4 images which if you open one by one, will give you an idea of what I am talking about.

However I couldn't take a screen shot with a tool tip displaying "Label and Value" but you get the idea.

Here are the links.

http://www.patel.com.au/1.jpg
http://www.patel.com.au/2.jpg
http://www.patel.com.au/3.jpg
http://www.patel.com.au/4.jpg

Cheers

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Apr 13, 2005 9:35 am

Hi Nirav,

You can use the MarkTipsTool's OnGetText event to customize the text the tool will display.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Command Alkon
Newbie
Newbie
Posts: 12
Joined: Thu Oct 28, 2004 4:00 am

Post by Command Alkon » Thu Apr 14, 2005 9:01 pm

Thank you Narcis,

Actually I was wondering if it is possible to extract the values without using MarkTip..?

Cheers

Pep
Site Admin
Site Admin
Posts: 3298
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Apr 14, 2005 11:50 pm

Hi,

yes, you can get the values using the OnClick event of the Series which return the Series and the ValueIndex which has been clicked :
procedure TForm1.Series1Click(Sender: TChartSeries; ValueIndex: Integer;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);

With this info you can get the values using :
x:=Series1.XValue[ValueIndex];
y:=Series1.YValue[ValueIndex];

Post Reply