File: main.pas

package info (click to toggle)
lazarus 4.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 275,760 kB
  • sloc: pascal: 2,341,904; xml: 509,420; makefile: 348,726; cpp: 93,608; sh: 3,387; java: 609; perl: 297; sql: 222; ansic: 137
file content (106 lines) | stat: -rw-r--r-- 2,198 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
unit Main;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
  Spin, TAGraph, TASeries, TASources, TAStyles, TAChartUtils;

type

  { TForm1 }

  TForm1 = class(TForm)
    Chart1: TChart;
    BarSeries: TBarSeries;
    cb3D: TCheckBox;
    ChartStyles1: TChartStyles;
    cbRotated: TCheckBox;
    cbShowLabels: TCheckBox;
    cmbShape: TComboBox;
    lblShape: TLabel;
    Panel1: TPanel;
    RandomChartSource1: TRandomChartSource;
    procedure cb3DChange(Sender: TObject);
    procedure cbRotatedChange(Sender: TObject);
    procedure cbShowLabelsChange(Sender: TObject);
    procedure cmbShapeChange(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private

  public

  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.cb3DChange(Sender: TObject);
begin
  if cb3D.Checked then
    BarSeries.Depth := 20
  else
    BarSeries.Depth := 0;
end;

procedure TForm1.cbRotatedChange(Sender: TObject);
begin
  if cbRotated.Checked then begin
    BarSeries.AxisIndexX := 0;
    BarSeries.AxisIndexY := 1;
  end else begin
    BarSeries.AxisIndexX := 1;
    BarSeries.AxisIndexY := 0;
  end;
end;

procedure TForm1.cbShowLabelsChange(Sender: TObject);
begin
  BarSeries.Marks.Visible := cbShowLabels.Checked;
end;

procedure TForm1.cmbShapeChange(Sender: TObject);
begin
  BarSeries.BarShape := TBarShape(cmbShape.ItemIndex);
  cb3DChange(nil);
end;

function RandomString(ALength: Integer): String;
var
  i: Integer;
begin
  SetLength(Result, ALength);
  Result[1] := Char(ord('A') + Random(26));
  for i := 2 to ALength do
    Result[i] := Char(ord('a') + Random(26));
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  i, j: Integer;
  s: String;
begin
  RandSeed := 1;
  BarSeries.Marks.Style := smsLabel;
  BarSeries.Marks.YIndex := -1;
  BarSeries.ListSource.YCount := 3;
  BarSeries.ListSource.LabelSeparator:= ';';
  for i := 0 to 5 do
  begin
    s := RandomString(1 + Random(4));
    for j := 2 to BarSeries.ListSource.YCount do
      s := s + ';' + RandomString(1 + Random(4));
    BarSeries.AddXY(i, 20+Random*100, [20+Random*100, 20+Random*100], s);
  end;
end;

end.