Page 1 of 1

Help on hover

Posted: Sat Jan 31, 2015 3:32 pm
by 16570912
Hi,

I installed an update of TChart and discovered that points of my graph are highlighted when the mouse is hovered over these points.
I have searched sample application, help, support forum etc. (using hover, highlight etc as key words) but I am unable to find info on events and/or properties that allow me to use this feature.

To begin, I would like to use an event to display a series' Name, X and Y values in some controls on my form. Can you point me to some info that describes these features (help topics, forum entries, etc) ?

Thanks!

Re: Help on hover

Posted: Mon Feb 02, 2015 9:27 am
by yeray
Hello,

There's an overview of this feature and the possibilities it supports at the What's New document, under "Mouse Hovering".
Softdrill wrote:To begin, I would like to use an event to display a series' Name, X and Y values in some controls on my form. Can you point me to some info that describes these features (help topics, forum entries, etc) ?
There's also a tool named TMarksTipTool that allows you to do things like this. You can take a look at the examples under "All features\Welcome !\Tools\Mark tips" in the "Features Demo" program shipped with the installation.
As with the regular Marks, you set it to show several predefined styles:

Code: Select all

  TSeriesMarksStyle=( smsValue,             { 1234 }
                      smsPercent,           { 12 % }
                      smsLabel,             { Cars } // If label is empty, no mark will be displayed
                      smsLabelPercent,      { Cars 12 % }
                      smsLabelValue,        { Cars 1234 }
                      smsLegend,            { (Legend.Style) }
                      smsPercentTotal,      { 12 % of 1234 }
                      smsLabelPercentTotal, { Cars 12 % of 1234 }
                      smsXValue,            { 1..2..3.. or 21/6/2014 }
                      smsXY,                { 123 456 }
                      smsSeriesTitle,       { Series1 }
                      smsPointIndex,        { 1..2..3... }
                      smsPercentRelative,   { 100%..90%..120%... }
                      smsLabelPercentValue, { Cars 12 % 1234 }
                      smsLabelOrValue       { Cars or 1234 }  // If label is empty, Value will be used
                      );
If you want further customization in this tool, you can capture the tool's OnGetText event to modify the text being displayed on the same.

Finally, if you want to do other actions when the mouse is over a series, you could always make it yourself using the OnMouseMove event. Ie:

Code: Select all

uses Series, TeeTools;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;

  Chart1.AddSeries(TPointSeries).FillSampleValues();

  Chart1.OnMouseMove:=Chart1MouseMove;
end;

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var valueIndex: Integer;
begin
  valueIndex:=Chart1[0].Clicked(X, Y);
  if valueIndex>-1 then
  begin
    //do whatever you want
  end;
end;

Re: Help on hover

Posted: Tue Feb 03, 2015 7:53 pm
by 16570912
Clear... thanks!

One more thing (hopefully it's not too dumb a question): how do I access Mark Tips Tool's properties and events in the IDE?
I opened the chart's editor and added a Mark Tip Tool. Now I like to implement the OnGetText and CancelHint events, but I cannot find these in the IDE (nor can I select the Mark Tip).
Should I manually declare, implement and assing these event handlers in code?

Thanks, Mark

Re: Help on hover

Posted: Wed Feb 04, 2015 8:13 am
by yeray
Hello,

You can find the ChartTools (and the Series) and its events in the Object Inspector:
2015-02-04_0908.png
2015-02-04_0908.png (2.36 KiB) Viewed 6845 times

Re: Help on hover

Posted: Wed Feb 04, 2015 8:08 pm
by 16570912
Thanks for that. I overlooked the Structure treeview because I expected the ChartTool to appear in the drop-down box in the Object Inspector.
Strangely enough; once it's been selected in the treeview, it appears in the drop-down box... :roll: