unit UDin;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ToolWin, ExtCtrls, TeeProcs, TeEngine, Chart,
  StdCtrls, CheckLst;

type
  TForm1 = class(TForm)
    Chart1: TChart;
    CheckListBox1: TCheckListBox;
    Button1: TButton;
    Label1: TLabel;
    procedure CheckListBox1ClickCheck(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
uses Series;

var A: array[0..2] of array of double;

procedure TForm1.FormCreate(Sender: TObject);
var i: integer;
begin
 setlength(A[0],10);
 for i:=0 to 9 do A[0][i] := i + 1;
 setlength(A[1],10);
 for i:=0 to 9 do A[1][i] := 10 - i;
 setlength(A[2],10);
 for i:=0 to 9 do A[2][i] := 5;
end;

procedure TForm1.CheckListBox1ClickCheck(Sender: TObject);
var TmpSeries: TChartSeries;
begin
 if CheckListBox1.Checked[CheckListBox1.ItemIndex]
  then begin
   TmpSeries := TFastLineSeries.Create(Chart1);
   TmpSeries.Title := CheckListBox1.Items[CheckListBox1.ItemIndex];
   TmpSeries.AddArray((A[CheckListBox1.ItemIndex]));
   (TmpSeries as TFastLineSeries).LinePen.Width := 2;
   TmpSeries.ParentChart := Chart1;
   CheckListBox1.Items.Objects[CheckListBox1.ItemIndex] :=
                           Chart1.Series[Chart1.SeriesCount - 1];
  end
  else CheckListBox1.Items.Objects[CheckListBox1.ItemIndex].Free;
end;

procedure TForm1.Button1Click(Sender: TObject);
var i: integer;
begin
 for i:=0 to 2 do begin
  SetLength(A[i],Length(A[i])+1);
  A[i][High(A[i])] := i;
 end;
 for i:=0 to CheckListBox1.Count - 1 do
  if CheckListBox1.Checked[i]
   then (CheckListBox1.Items.Objects[i] as TChartSeries).Add(A[i][High(A[i])]);
end;

end.
