TMarksTipTool

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
AMS
Newbie
Newbie
Posts: 24
Joined: Wed Mar 31, 2004 5:00 am
Location: South Africa
Contact:

TMarksTipTool

Post by AMS » Thu Jul 29, 2004 9:45 am

I want to display an alternative Series title when I mouse over the legend as well, can this control do it for me?

Any help will really be appreciated!



-Hendrik

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

Post by Pep » Fri Jul 30, 2004 9:40 am

Hi Hendrik,

yes, this can be done. Using the following code you can check when the mouse is over the Legend items, and also show a text. In this example will show the XValue of the Legend item.

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues(10);
Chart1.View3D := False;
end;

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var tmp, tmpL : Integer;
begin
  With Chart1 do
  begin
    If (Series1.Clicked(X, Y) <> -1) And (OnSeriesPoint = False) Then
    begin
     Canvas.Brush.Style := bsSolid;
     Canvas.Pen.Color := clBlack;
     Canvas.Brush.Color := clWhite;
     canvas.TextOut(x+10,y,FormatFloat('#.00',Series1.XScreenToValue(x))+','+FormatFloat('#.00',Series1.YScreenToValue(y)));
     OnSeriesPoint := True;
    End;
    //Repaint Chart to clear Textoutputted Mark
    If (Series1.Clicked(X, Y) = -1) And (OnSeriesPoint = True) Then
    begin
      OnSeriesPoint := False;
      Repaint;
    End;

    tmpL := Chart1.Legend.Clicked(X, Y);
    If (tmpL <> -1) And ((tmpL <> tmpL2) Or (OnLegendPoint = False)) Then
    begin
       Repaint;
       Canvas.Brush.Color := Series1.LegendItemColor(tmpL);
       Canvas.Rectangle( X, Y, X + 20, Y + 20);
       Canvas.Brush.Color := clWhite;
       canvas.TextOut(x+7,y+7,FormatFloat('#.00',Series1.XValues.Items[Series1.LegendToValueIndex(tmpl)]));
       tmpL2 := tmpL;
       OnLegendPoint := True;
    End;

    If (Legend.Clicked(X, Y) = -1) And (OnLegendPoint = True) Then
    begin
       OnLegendPoint := False;
       Repaint;
    End;
  End;
end;

Post Reply