unit drugimulti;

interface

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

type
  TForm1 = class(TForm)
    Chart1: TChart;
    Chart2: TChart;
    Series1: TLineSeries;
    Series2: TLineSeries;
    Series3: TBarSeries;
    Series4: TBarSeries;
    Button1: TButton;
    Series5: TLineSeries;
    Series6: TFastLineSeries;
    Button2: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Chart1ClickSeries(Sender: TCustomChart; Series: TChartSeries;
      ValueIndex: Integer; Button: TMouseButton; Shift: TShiftState; X,
      Y: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var i,j:integer;
begin
  with Chart1 do  //max ilosc serii danych na wykresie to SeriesCount
    for i:=0 to SeriesCount-1 do
    begin
      Series[i].Clear;
      for j:=1 to 5 do  //Series[i].Count to ilosc danych w jedne serii
        Series[i].AddXY(j,1+Random(10));//do kazdej serii dodawanych jest 5 liczb losowych
    end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var i:integer;
begin
   //po kliknięciu przycisku do kazdej serii dodawana jest jedna dana
    with Chart2 do
     for i:=0 to SeriesCount-1 do
       Series[i].Add(1+Random(10));
end;

procedure TForm1.Chart1ClickSeries(Sender: TCustomChart;
  Series: TChartSeries; ValueIndex: Integer; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
 //dla wszystkich wykresów to samo będzie bez instrukcji if

  //zmiana koloru linii wybranego wykresu
  if Series.Name='Series1' then Series.SeriesColor:=clLime;
  //kasowanie wykresu
  if Series.Name='Series2' then Series.Active:=false;
  if Series.Name='Series5' then Series.Clear;
end;

end.
