Page 1 of 1

Legend with Scrollbar - Error

Posted: Thu Apr 19, 2012 2:52 am
by 9341927
Hi,

I use FastLine graph and display Legend with checkbox on the graph. Series will be added dynamically.

When there are multiple series, The legend will show the a few series ( with Vertical scroll bar. When you click down arrow to scroll down, I got the following error. "List index out of bounds (10)". Even when I hit "OK" button to close the msg box, it appears again and again. Then the program couldn't run properly.

Environment: Delphi 2010
Current TeeChart version: V2012 pro
Previous TeeChart Version: version 8 pro

Image

The program was implemented in TeeChart Pro version 8 and now it is upgraded to version 2012. It happens both version 8 and v2012.

Can anyone please help me out to solve this error?

Re: Legend with Scrollbar - Error

Posted: Thu Apr 19, 2012 10:14 am
by narcis
Hi Matt,

I'm not able to reproduce the issue here using v2012.05.120327 and the code snippet below. Can you please modify it so that we can reproduce the problem here?

Code: Select all

uses Series, TeeLegendScrollBar;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  for i:=0 to 50 do
    Chart1.AddSeries(TFastLineSeries.Create(Self)).FillSampleValues;

  Chart1.Tools.Add(TLegendScrollBar.Create(Self));
  Chart1.View3D:=False;
end;

Re: Legend with Scrollbar - Error

Posted: Thu May 03, 2012 5:23 am
by 9341927
Hi Narcis,

Last days, I was trying to regenrate the error from your sample program but I couldn't able to do it.

But yesterday, I found out the cause of the problem. The cause is there are extra hidden series. For instance, I have 8 series added to the chart. But there is something worng in the program or the library, the total series count as 10. So, Scrollbar thinks there are 10 series. That's why when i hit down arrow key to go down and i get "List index out of bunds" error when i hit 9th series. Beause there is no 9th or 10th series in the graph.


Do you have any guides to fix the problem?
Can we have Up arrow or Down arrow Key event from Scrollbar and how?

Thanks in advance.

Re: Legend with Scrollbar - Error

Posted: Thu May 03, 2012 3:32 pm
by yeray
Hi Matt,
Matt Venkat wrote:Last days, I was trying to regenrate the error from your sample program but I couldn't able to do it.

But yesterday, I found out the cause of the problem. The cause is there are extra hidden series. For instance, I have 8 series added to the chart. But there is something worng in the program or the library, the total series count as 10. So, Scrollbar thinks there are 10 series. That's why when i hit down arrow key to go down and i get "List index out of bunds" error when i hit 9th series. Beause there is no 9th or 10th series in the graph.

Do you have any guides to fix the problem?
It has to be something in your application that is creating this series. Could you please try to arrange a simple example project we can run as is to reproduce the problem here?
Thanks in advance.
Matt Venkat wrote:Can we have Up arrow or Down arrow Key event from Scrollbar and how?
You can use the chart's OnKeyDown event to check if the TeeKey_Down/TeeKey_Up keys have been pressed. And you could combine it with the OnMouseMove event if you want to check the keys only when the mouse is in the Legend area. For example:

Code: Select all

var MouseInLegend: Boolean;

procedure TForm1.FormCreate(Sender: TObject);
begin
  MouseInLegend:=false;
end;

procedure TForm1.Chart1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if MouseInLegend then
  case Key of
    TeeKey_Down: Caption:='Down!';
    TeeKey_Up: Caption:='Up!';
  end;
end;

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  MouseInLegend:=(Chart1.Legend.Clicked(X,Y)>-1);
end;