Page 1 of 1

Click event for Marks

Posted: Fri Aug 15, 2008 7:17 am
by 10547875
Hi!

In my current product I have a line chart with Marks (marking the points; the marks are multiline and consist of Label and Value).

I would like my users to be able to click on the Mark (click event) and I would like to extract the text of the Mark and then for e.g. activate some other code based on the contents of the Mark text (e.g. start a special editor or place or highlight a special section in a list box etc).

Is there a mouse click event for Marks? And I need to get the text in that context... (I think there is something like OnGetMarkText).

Thanks.

Br, Tim

Posted: Mon Aug 18, 2008 9:11 am
by yeray
Hi Tim,

You could use Series1.Marks.Clicked(X,Y) to retrieve the index of the clicked mark at OnMouseDown event. And then, you could obtain the Mark text of the according point at OnGetMarkText. Something as folowing:

Code: Select all

//...
var index: Integer;

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  index := Series1.Marks.Clicked(X,Y);
  Chart1.Draw;
end;

procedure TForm1.Series1GetMarkText(Sender: TChartSeries;
  ValueIndex: Integer; var MarkText: String);
begin
  if (index > 0) and (ValueIndex = index) then
    Caption := MarkText;
end;

Posted: Mon Aug 18, 2008 10:22 am
by 10547875
Thanks.

I'll try this...

/Tim

Posted: Mon Aug 18, 2008 11:29 am
by 10547875
Hi!

I have implemented this now and it seems to work (using RAD C++ 2007) and TChart VCL 8.02.

Note that the event is NOT exposed in any property so I had to add it manually. Actually No events of the Series is exposed in the object inspector???

In H:
void __fastcall Series1GetMarkText(TChartSeries *Sender,int ValueIndex,AnsiString &MarkText);

In CPP:
void __fastcall TProtocolEditorForm::Series1GetMarkText(TChartSeries *Sender,
int ValueIndex, AnsiString &MarkText)
{
//

if( (iMarkIndex > 0) && (ValueIndex == iMarkIndex))
{
edtDescription->Text = MarkText;
}

//ShowMessage("We are in get mark text");

}

In Form: (note line: OnGetMarkText = Series1GetMarkText) added by hand.

object Series1: TLineSeries
ColorEachPoint = True
Marks.Arrow.Visible = True
Marks.Callout.Brush.Color = clWhite
Marks.Callout.Style = psDownTriangle
Marks.Callout.Visible = True
Marks.Callout.Arrow.Visible = True
Marks.Callout.Distance = 12
Marks.Callout.Length = 18
Marks.Bevel = bvRaised
Marks.Gradient.Direction = gdTopBottom
Marks.Gradient.StartColor = 12615680
Marks.Gradient.Visible = True
Marks.Margins.Bottom = 8
Marks.MultiLine = True
Marks.Shadow.Color = 8947848
Marks.Style = smsLabelValue
Marks.Visible = True
ShowInLegend = False
OnGetMarkText = Series1GetMarkText
LinePen.Width = 3
Pointer.InflateMargins = True
Pointer.Style = psCircle
Pointer.Visible = False
Stairs = True
XValues.DateTime = True
XValues.Name = 'X'
XValues.Order = loAscending
YValues.Name = 'Y'
YValues.Order = loNone
end

Posted: Wed Aug 20, 2008 10:23 am
by Pep
Hi Tim,

it's very strange, I've just test it here using the latest TeeChart Pro sources and all the Series events are correctly displayed into the Object Inspector.

You could try to reinstall the TeeChart Components, it could be due to an installation problem.

Posted: Wed Aug 20, 2008 10:32 am
by 10547875
Thanks!
I am waiting for the official 8.03... before re-installing.

Posted: Wed Aug 20, 2008 12:44 pm
by 10547875
Just to clarify: The Chart1 Events are exposed. But when selecting Chart1.SeriesGroups[0].TSeriesGroup that Event Tab is empty. Or where can I see the event of the actual e.g. Line Series in the Editor???

In TChart I can see an event OnGetLegentText but not the Series1GetMarkText... Am I looking in the right place??

Question:

If I use UNINSTALL, does the uninstaller replace the original files that came with RAD 2007?

If I then reinstall 8.0x will it redo the backup?

Are there some files from 8.0x installation I need to remove manually before reinstalling?

Thanks!

/Tim

Posted: Thu Aug 21, 2008 9:42 am
by yeray
Hi Tim,

Yes, there aren't events for series groups, so the series group event list is empty.

If you add the series at runtime, by code, the Object Inspector won't show the series' related properties or events. In this case you should set the properties and the events you wish by code.

But if you add a series at design time, through the chart editor, it should appear the new series at the Object Inspector combo list. If they are not listed in that combo list (with the form1 and the chart1), you may have some strange installation problem. Then we recommend you to execute the TeeInstall application to uninstall teechart, look and remove old teechart references at the search and library paths, and finally reinstall teechart executing TeeInstall again.

Finally, if you prefer to uninstall teechart completely, I recommend you to run the uninstaller. Then, look at your program files if there remain any TeeChart file or folder and remove it manually. Also, you could search at your system32 folder for *tee* files remove/backup them. Then you should do the same as above, search and remove the references to old teechart files/folders at four search and library paths from your IDE. And now you should be able to restore the backup files that the installer created the first time you ran it (if you selected to make a backup when prompted).

Posted: Thu Aug 21, 2008 9:51 am
by 10547875
Hi!

You are correct! I just found the object! :-)

Installation seems ok!

THANKS!!!!

/Tim