Series Clicked and Marktip Text

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
McMClark
Newbie
Newbie
Posts: 50
Joined: Thu Apr 15, 2004 4:00 am

Series Clicked and Marktip Text

Post by McMClark » Tue Jan 03, 2006 5:01 pm

I am using TeeChart 7.05 with Delphi 2005 in a vcl application. I have a dbChart that I programmatically add multiple series based on a query. I have the tool MarkTip enabled in the dbChart. I want to be able to have my application detect what series the user clicks and the value of the MarkTip text at that time. Can anyone tell me how to do that?

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

Post by Pep » Thu Jan 05, 2006 9:54 am

Hi,

this can be easily done using the MarksTipTool, setting Series to (all) and Mouse Action to "Click", and them use the following events :

Code: Select all

procedure TForm1.ChartTool1GetText(Sender: TMarksTipTool;
  var Text: String);
begin
label1.caption := ' MarkText: ' + text;
end;

procedure TForm1.Chart1ClickSeries(Sender: TCustomChart;
  Series: TChartSeries; ValueIndex: Integer; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
label2.caption := 'Series : ' + Series.Name;
end;

McMClark
Newbie
Newbie
Posts: 50
Joined: Thu Apr 15, 2004 4:00 am

Series Clicked and Marktip Text

Post by McMClark » Thu Jan 26, 2006 6:21 pm

Thanks the Tooltip worked but the series name is not being passed. I made sure that the series have names. What could I be doing wrong?

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

Post by Narcís » Fri Jan 27, 2006 9:33 am

Hi McMClark,

You can try using Chart1[ValueIndex].Name or Chart1[ValueIndex].Title.
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

McMClark
Newbie
Newbie
Posts: 50
Joined: Thu Apr 15, 2004 4:00 am

Post by McMClark » Sat Feb 04, 2006 7:08 pm

Thanks.

I want to enable the MarkTipTool in DBCharts that I build at runtime. I want the tool tip to show the X value when the cursor passes over a point on the graph. How can I do that. The code I have is

var
DBChart1: TDBChart;
intList: integer;
begin

for intlist := 1 to NumOfCharts Do
begin
DBChart1 := TDBChart.Create(Self);
DBChart1. Top := LastChartTop + LastChartWidth + 10
DBChart1.Height := DefaultHeight;

tmpLineSeries := TLineSeries.Create(self);
DBChart1.AddSeries(tmpLineSeries);
With tmpLineSeries do
Begin
DataSource:= TempResults_Query1;
YValues.ValueSource := 'Score';
XLabelsSource := 'PublicationDate';
Pointer.Visible := False;
Title := strSubject;

CheckDataSource;
OnGetPointerStyle:=Series1GetPointerStyle;
end;
end;

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

Post by Narcís » Mon Feb 06, 2006 8:29 am

Hi McMClark,

Yes, you can add the following to your coee to achieve what you request:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  DBChart1[0].FillSampleValues();

  DBChart1.Tools.Add(TCursorTool.Create(self));
  (DBChart1.Tools.Items[0] as TCursorTool).FollowMouse:=true;
  (DBChart1.Tools.Items[0] as TCursorTool).OnChange:=ChartTool1Change;
  (DBChart1.Tools.Items[0] as TCursorTool).Style:=cssVertical;
end;

procedure TForm1.ChartTool1Change(Sender: TCursorTool; x, y: Integer;
  const XValue, YValue: Double; Series: TChartSeries; ValueIndex: Integer);
begin
  DBChart1.Title.Text[0]:='Cursor X Value: '+FloatToStr(XValue);
end;
You'll also have to include TeeTools unit into your uses section.
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

Post Reply