Hi !
Is it possible to detect if the mouse is over an item/series in the chartlistbox (without clicking the mouse)?
Let´s think about the following situation:
You have 10 or more active curves in your chart. Now the users hovers over the chartlistbox and the series items.
If there is any chance to detect the series where the mouse is over this series could be painted with a line pen width +1 as long as the mouse is over the series.
Greetz
Dominik
Chartlistbox and Hover Effect?
Re: Chartlistbox and Hover Effect?
Hi Dominik,
Taking this example as reference, it is easy to obtain the following solution:
Taking this example as reference, it is easy to obtain the following solution:
Code: Select all
uses series;
var selectedSeries: Integer;
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
chart1.View3D:=false;
for i := 0 to 5 do
begin
Chart1.AddSeries(TFastLineSeries.Create(self));
Chart1[i].FillSampleValues();
end;
Chart1.Legend.CheckBoxes:=true;
selectedSeries:=-1;
end;
procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var i: Integer;
tmpPnt: TPoint;
tmpRect: TRect;
begin
tmpPnt.X:=X;
tmpPnt.Y:=Y;
for i:=0 to Chart1.SeriesCount-1 do
begin
tmpRect.Left:=Chart1.Legend.Left;
tmpRect.Right:=Chart1.Legend.Left + Chart1.Legend.Width - 1;
tmpRect.Bottom:=Chart1.Legend.Item[i].Top + Chart1.Legend.Item[i].SymbolRect.Bottom - Chart1.Legend.Item[i].SymbolRect.Top + 3;
if (i = 0) then tmpRect.Top:=Chart1.Legend.Item[i].Top-3
else tmpRect.Top:=Chart1.Legend.Item[i].Top-2;
if PtInRect(tmpRect,tmpPnt) then
begin
if selectedSeries>-1 then Chart1[selectedSeries].Pen.Width:=1;
selectedSeries:=i;
Chart1[selectedSeries].Pen.Width:=3;
break;
end;
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Chartlistbox and Hover Effect?
Hi Yeray,
that´s not what I need.
I want to hover over the ChartListBox - not over the Chart.
In easy words I need this:
Hover over a series in the ChartListBox and repaint the corresponding series with a line width +1 (as long as the hover takes).
that´s not what I need.
I want to hover over the ChartListBox - not over the Chart.
In easy words I need this:
Hover over a series in the ChartListBox and repaint the corresponding series with a line width +1 (as long as the hover takes).
Re: Chartlistbox and Hover Effect?
Hi Dominik,
Excuse me, I missed that. But the solution for a ChartListBox isn't very different:
Excuse me, I missed that. But the solution for a ChartListBox isn't very different:
Code: Select all
uses series;
var selectedSeries: Integer;
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
ChartListBox1.Chart:=Chart1;
chart1.View3D:=false;
for i := 0 to 5 do
begin
Chart1.AddSeries(TFastLineSeries.Create(self));
Chart1[i].FillSampleValues();
end;
Chart1.Legend.Visible:=false;
selectedSeries:=-1;
end;
procedure TForm1.ChartListBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var i: Integer;
tmpPnt: TPoint;
tmpRect: TRect;
begin
tmpPnt.X:=X;
tmpPnt.Y:=Y;
for i:=0 to Chart1.SeriesCount-1 do
begin
if PtInRect(ChartListBox1.ItemRect(i),tmpPnt) then
begin
if selectedSeries>-1 then Chart1[selectedSeries].Pen.Width:=1;
selectedSeries:=i;
Chart1[selectedSeries].Pen.Width:=2;
break;
end;
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |