control TChartSeries hover effect manually

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
niotronic
Newbie
Newbie
Posts: 2
Joined: Mon Jun 27, 2016 12:00 am

control TChartSeries hover effect manually

Post by niotronic » Mon Sep 12, 2016 4:19 pm

Hi,

I would like to enable/disable the hovering for the whole TLineSeries manually, for example enable it in the OnClick event of a series in order to highlight some series - is there a way to do that ?

Best regards,

Klaus

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: control TChartSeries hover effect manually

Post by Yeray » Tue Sep 13, 2016 7:50 am

Hi Klaus,

Do you mean doing something like this?

Code: Select all

uses Series;

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

  with Chart1.AddSeries(TLineSeries) do
  begin
    FillSampleValues();
    OnClick:=SeriesClick;
  end;

  Chart1.Hover.Visible:=false;
end;

procedure TForm1.SeriesClick(Sender:TChartSeries; ValueIndex:Integer; Button:TMouseButton; Shift: TShiftState;
                          X, Y: Integer);
begin
  if Sender.Pen.Width=1 then
    Sender.Pen.Width:=3
  else
    Sender.Pen.Width:=1;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

niotronic
Newbie
Newbie
Posts: 2
Joined: Mon Jun 27, 2016 12:00 am

Re: control TChartSeries hover effect manually

Post by niotronic » Tue Sep 13, 2016 10:20 am

Dear Yeray,

thanks for the suggestion to change the pen width in the onclick event ! This is an option but does not a have similar look when compared with hovering. Is there a way to make it look like the hover effect ? - Can I turn on/off the hovering manually at runtime for the whole series - i.e. show the hover effect for all connecing lines, and not only the selected element like its standard behaviour when Chart1.Hover.Visible:=TRUE ?

Best regards,

Klaus

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: control TChartSeries hover effect manually

Post by Yeray » Wed Sep 14, 2016 11:01 am

Hello,

You can assign the pen and color to the whole series at the OnClick eventif you want. Ie:

Code: Select all

uses Series, TeCanvas;
var oldPen: TTeePen;

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

  with Chart1.AddSeries(TLineSeries) do
  begin
    FillSampleValues();
    OnClick:=SeriesClick;
  end;

  oldPen:=TTeePen.Create(nil);
  Chart1.Hover.Visible:=false;
end;

procedure TForm1.SeriesClick(Sender:TChartSeries; ValueIndex:Integer; Button:TMouseButton; Shift: TShiftState;
                          X, Y: Integer);
begin
  if Sender.Pen.Width=1 then
  begin
    oldPen.Assign(Sender.Pen);
    oldPen.Color:=Sender.Color;

    Sender.Pen.Assign(Chart1.Hover.Pen);
    Sender.Color:=Chart1.Hover.Pen.Color;
  end
  else
  begin
    Sender.Pen.Assign(oldPen);
    Sender.Color:=oldPen.Color;
  end;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply