unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Chart1: TChart;
    Button1: TButton;
    Series1: TLineSeries;
    Button2: TButton;
    Button3: TButton;
    procedure Button3Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var x:single;
begin
  Series1.Clear;
  x:=-10;
  repeat
     Series1.AddXY(x, 2*x*sin(x) );
     x:=x+0.5;
  until  x>10;

end;

procedure TForm1.Button2Click(Sender: TObject);
var i:integer;
begin
    with Series1 do
    begin
    for i:=0 to Count-2 do
      if YValue[i+1]>YValue[i] then //funkcja rosnąca
       ValueColor[i+1]:=clYellow
      else ValueColor[i+1]:=clRed;  //funkcja malejąca
      Series1.Repaint;
  end;
end;

procedure TForm1.Button3Click(Sender: TObject);
var i:integer;
begin
  with Series1 do
  begin
    for i:=0 to Count-2 do
      if XValues.Value[i]>0 then ValueColor[i]:=clRed  //lub XValue[i]>0
      else ValueColor[i]:=clGreen;
    Series1.Repaint;
  end;
end;

end.
