unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
  NxIntf6,
  NxColumns6, NxGridView6, NxControls6, NxCustomGrid6, NxVirtualGrid6, NxGrid6, Vcl.StdCtrls, Vcl.ExtCtrls;

type
  TForm1 = class(TForm)
    NextGrid61: TNextGrid6;
    NxReportGridView61: TNxReportGridView6;
    NxTextColumn61: TNxTextColumn6;
    NxChartColumn61: TNxChartColumn6;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
    procedure CheckBox3Click(Sender: TObject);
    procedure NxChartColumn61ChartColor(Sender: TObject; Index: Integer; var BorderColor, FillColor: TColor);
    procedure Button1Click(Sender: TObject);
  private
    FChartLength: Integer;
  end;

var
  Form1: TForm1;
  Data: array of Double;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  NextGrid61.Color := RGB(64, 64, 64);
  NextGrid61.Font.Color := RGB(191, 191, 191);
  NextGrid61.ActiveView.GridLinesColor := RGB(89, 89, 89);
  NxChartColumn61.BaseLinePen.Color := NextGrid61.ActiveView.GridLinesColor;
  NextGrid61.UserDefinedColorPalette.ButtonColor := NextGrid61.Color;
  NxTextColumn61.Header.Color := NextGrid61.Color;
  NxChartColumn61.Header.Color := NextGrid61.Color;
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  if TCheckBox(Sender).Checked then
    NxChartColumn61.ChartStyles := NxChartColumn61.ChartStyles + [csLine]
  else
    NxChartColumn61.ChartStyles := NxChartColumn61.ChartStyles - [csLine];
end;

procedure TForm1.CheckBox2Click(Sender: TObject);
begin
  if TCheckBox(Sender).Checked then
    NxChartColumn61.ChartStyles := NxChartColumn61.ChartStyles + [csDots]
  else
    NxChartColumn61.ChartStyles := NxChartColumn61.ChartStyles - [csDots];
end;

procedure TForm1.CheckBox3Click(Sender: TObject);
begin
  if TCheckBox(Sender).Checked then
    NxChartColumn61.ChartStyles := NxChartColumn61.ChartStyles + [csBars]
  else
    NxChartColumn61.ChartStyles := NxChartColumn61.ChartStyles - [csBars];
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  FChartLength := 0;
  SetLength(Data, 20);
  Data[0] := 6;
  Data[1] := 8;
  Data[2] := 11;
  Data[3] := 11;
  Data[4] := 3;
  Data[5] := -4;
  Data[6] := -7;
  Data[7] := -24;
  Data[8] := -27;
  Data[9] := -31;
  Data[10] := -8;
  Data[11] := -3;
  Data[12] := 1;
  Data[13] := 5;
  Data[14] := 8;
  Data[15] := 10;
  Data[16] := 12;
  Data[17] := 18;
  Data[18] := 17;
  Data[19] := 15;

  NextGrid61.AddRow;
  NextGrid61.Cell[NxTextColumn61.Index, NextGrid61.LastAddedRow].AsString := 'Car sales';
  NextGrid61.Cell[NxChartColumn61.Index, NextGrid61.LastAddedRow].Data := Data;
end;

procedure TForm1.NxChartColumn61ChartColor(Sender: TObject; Index: Integer; var BorderColor, FillColor: TColor);
begin
  if Data[Index] >= 8 then
    FillColor := RGB(68, 114, 196)
  else if Data[Index] <= -8 then
    FillColor := RGB(237, 125, 49)
  else FillColor := RGB(165, 165, 165);
  BorderColor := FillColor;
end;

end.
