Page 1 of 1
control TChartSeries hover effect manually
Posted: Mon Sep 12, 2016 4:19 pm
by 16578564
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
Re: control TChartSeries hover effect manually
Posted: Tue Sep 13, 2016 7:50 am
by yeray
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;
Re: control TChartSeries hover effect manually
Posted: Tue Sep 13, 2016 10:20 am
by 16578564
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
Re: control TChartSeries hover effect manually
Posted: Wed Sep 14, 2016 11:01 am
by yeray
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;