Page 1 of 1
Series Clicked and Marktip Text
Posted: Tue Jan 03, 2006 5:01 pm
by 9337074
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?
Posted: Thu Jan 05, 2006 9:54 am
by Pep
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;
Series Clicked and Marktip Text
Posted: Thu Jan 26, 2006 6:21 pm
by 9337074
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?
Posted: Fri Jan 27, 2006 9:33 am
by narcis
Hi McMClark,
You can try using Chart1[ValueIndex].Name or Chart1[ValueIndex].Title.
Posted: Sat Feb 04, 2006 7:08 pm
by 9337074
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;
Posted: Mon Feb 06, 2006 8:29 am
by narcis
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.