Here is my own implementation, based on TChart.OnMouseWheel
event, simulating Legend scrolling (it is scrolled, but without any scroll bar - maybe it will be task for future):
procedure TForm1.Chart1MouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
function GetChartActiveSeriesCount(aChart: TChart): Integer;
var
iIdx: Integer;
begin
Result := 0;
for iIdx := 0 to aChart.SeriesCount-1 do
begin
if aChart.Series[iIdx].Active = True then
Inc(Result);
end;
end;
var
lCliMousePos: TPoint;
lActiveCount: Integer;
lChart: TChart;
begin
lChart := TChart(Sender);
lCliMousePos := lChart.ScreenToClient(MousePos);
if PtInRect(lChart.Legend.RectLegend, lCliMousePos) then
begin
if WheelDelta > 0 then
begin
if lChart.Legend.FirstValue > 0 then
lChart.Legend.FirstValue := lChart.Legend.FirstValue-1;
end
else
begin
lActiveCount := GetChartActiveSeriesCount(lChart);
if (lChart.Legend.FirstValue + lChart.Legend.NumRows) < lActiveCount then
lChart.Legend.FirstValue := lChart.Legend.FirstValue+1;
end;
end;
Handled := True;
end;
Also there are some tricks how to trigger TChart.OnMouseWheel
event, because Tchart cannot get focus it is needed to play with Main Form OnMouseWheel
event or WM_MOUSEWHEEL
windows message. HowTos here:
http://delphi.about.com/od/delphitips2010/qt/delphi-redirect-mouse-wheel-control-under-the-mouse.htm or here: http://delphi.about.com/od/delphitips2010/qt/timage-handling-mouse-wheel-messages.htm