Project CHARTDB
Project Structure
CHARTDB.DPR
program ChartDb;
uses
Forms,
ChartDbF in 'ChartDbF.pas' {Form1};
{$R *.RES}
begin
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
CHARTDBF.PAS
unit ChartDbF;
interface
uses
SysUtils, Windows, Messages, Classes, Graphics, Controls,
Forms, Dialogs, Grids, DBGrids, DB, DBTables, ExtCtrls, TeEngine, Series,
TeeProcs, Chart, DBChart, StdCtrls;
type
TForm1 = class(TForm)
Table1: TTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
DBChart1: TDBChart;
Series1: TPieSeries;
Splitter1: TSplitter;
RadioArea: TRadioButton;
RadioPopulation: TRadioButton;
procedure DataSource1StateChange(Sender: TObject);
procedure RadioPopulationClick(Sender: TObject);
procedure RadioAreaClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.DataSource1StateChange(Sender: TObject);
var
Title: string;
begin
case Table1.State of
dsBrowse: Title := 'Browse';
dsEdit: Title := 'Edit';
dsInsert: Title := 'Insert';
else
Title := 'Other state';
end;
Caption := 'Grid Demo - ' + Title;
end;
procedure TForm1.RadioPopulationClick(Sender: TObject);
begin
DBChart1.Title.Text [0] := 'Population of Countries';
(DBChart1.Series [0] as TPieSeries).
PieValues.ValueSource := 'Population';
end;
procedure TForm1.RadioAreaClick(Sender: TObject);
begin
DBChart1.Title.Text [0] := 'Area of Countries';
(DBChart1.Series [0] as TPieSeries).
PieValues.ValueSource := 'Area';
end;
end.
CHARTDBF.DFM
object Form1: TForm1
Left = 236
Top = 106
Width = 511
Height = 444
ActiveControl = DBGrid1
Caption = 'ChartDB'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clBlack
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
PixelsPerInch = 96
TextHeight = 13
object Splitter1: TSplitter
Left = 0
Top = 201
Width = 503
Height = 0
Cursor = crVSplit
Align = alTop
end
object DBGrid1: TDBGrid
Left = 0
Top = 0
Width = 503
Height = 201
Align = alTop
DataSource = DataSource1
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clBlack
TitleFont.Height = -11
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
Columns = <
item
Alignment = taRightJustify
Color = clBtnShadow
Expanded = False
FieldName = 'Name'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWhite
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
ReadOnly = True
Title.Alignment = taRightJustify
Title.Caption = 'Country'
Title.Font.Charset = DEFAULT_CHARSET
Title.Font.Color = clBlack
Title.Font.Height = -11
Title.Font.Name = 'MS Sans Serif'
Title.Font.Style = [fsBold]
Width = 133
Visible = True
end
item
Expanded = False
FieldName = 'Capital'
Width = 83
Visible = True
end
item
Expanded = False
FieldName = 'Continent'
Font.Charset = DEFAULT_CHARSET
Font.Color = clBlack
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = [fsItalic]
PickList.Strings = (
'Africa'
'Asia'
'Australia'
'Europe'
'North America'
'South America')
Width = 95
Visible = True
end
item
Expanded = False
FieldName = 'Area'
Width = 72
Visible = True
end
item
Expanded = False
FieldName = 'Population'
Visible = True
end>
end
object DBChart1: TDBChart
Left = 0
Top = 201
Width = 503
Height = 216
AllowPanning = pmNone
AllowZoom = False
AnimatedZoom = True
BackWall.Brush.Style = bsClear
BackWall.Pen.Visible = False
Title.Text.Strings = (
'Area of Countries')
AxisVisible = False
BottomAxis.Title.Caption = 'Name'
Chart3DPercent = 35
ClipPoints = False
Frame.Visible = False
LeftAxis.Title.Caption = 'Area'
Legend.Visible = False
View3DOptions.Elevation = 315
View3DOptions.Orthogonal = False
View3DOptions.Rotation = 360
View3DWalls = False
Align = alClient
TabOrder = 1
object RadioArea: TRadioButton
Left = 16
Top = 16
Width = 73
Height = 17
Caption = 'Area'
Checked = True
TabOrder = 0
TabStop = True
OnClick = RadioAreaClick
end
object RadioPopulation: TRadioButton
Left = 16
Top = 34
Width = 73
Height = 17
Caption = 'Population'
TabOrder = 1
OnClick = RadioPopulationClick
end
object Series1: TPieSeries
Marks.ArrowLength = 8
Marks.Frame.Visible = False
Marks.Visible = True
DataSource = Table1
Title = 'Area'
XLabelsSource = 'Name'
OtherSlice.Style = poBelowPercent
OtherSlice.Text = 'Others'
OtherSlice.Value = 2
PieValues.DateTime = False
PieValues.Name = 'Pie'
PieValues.Multiplier = 1
PieValues.Order = loNone
PieValues.ValueSource = 'Area'
end
end
object Table1: TTable
Active = True
DatabaseName = 'DBDEMOS'
TableName = 'COUNTRY.DB'
Left = 24
Top = 144
end
object DataSource1: TDataSource
DataSet = Table1
OnStateChange = DataSource1StateChange
Left = 80
Top = 144
end
end
|