TAChart: Show some dummy data in dbdemo to start with.

git-svn-id: trunk@54272 -
This commit is contained in:
wp 2017-02-25 17:27:17 +00:00
parent 9d64ee4506
commit 533405f98c
4 changed files with 41 additions and 21 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<Version Value="10"/>
<PathDelim Value="\"/>
<General>
<Flags>
@ -12,10 +12,11 @@
<MainUnit Value="0"/>
<Title Value="Chart db-aware demo"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
</General>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
@ -49,19 +50,19 @@
<Unit0>
<Filename Value="dbdemo.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="dbdemo"/>
</Unit0>
<Unit1>
<Filename Value="main.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Main"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="9"/>
<Version Value="11"/>
<PathDelim Value="\"/>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
@ -79,12 +80,6 @@
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
<UseMsgFile Value="True"/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">

View File

@ -10,6 +10,8 @@ uses
Forms, Main, MemDSLaz, TAChartLazarusPkg
{ you can add units after this };
{$R *.res}
begin
Application.Title := 'Chart db-aware demo';
Application.Initialize;

View File

@ -6,8 +6,9 @@ object Form1: TForm1
Caption = 'Form1'
ClientHeight = 300
ClientWidth = 547
OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '0.9.29'
LCLVersion = '1.7'
object Chart1: TChart
Left = 0
Height = 274
@ -15,10 +16,12 @@ object Form1: TForm1
Width = 347
AxisList = <
item
Minors = <>
Title.LabelFont.Orientation = 900
end
item
Alignment = calBottom
Minors = <>
end>
Foot.Brush.Color = clBtnFace
Foot.Font.Color = clBlue
@ -32,11 +35,14 @@ object Form1: TForm1
'TAChart'
)
Align = alClient
ParentColor = False
object Chart1LineSeries1: TLineSeries
ZPosition = 1
LinePen.Color = clTeal
LinePen.Width = 3
Pointer.HorizSize = 6
Pointer.Style = psCircle
Pointer.VertSize = 6
ShowPoints = True
Source = DbChartSource1
end
object Chart1BarSeries1: TBarSeries
@ -49,6 +55,8 @@ object Form1: TForm1
Top = 26
Width = 200
Align = alRight
AutoFillColumns = True
Color = clWindow
Columns = <>
DataSource = Datasource1
Scrollbars = ssAutoBoth
@ -75,19 +83,15 @@ object Form1: TForm1
item
Name = 'X'
DataType = ftFloat
Precision = 0
Size = 0
end
item
Name = 'Y'
DataType = ftFloat
Precision = 0
Size = 0
end>
left = 271
top = 60
end
object Datasource1: TDatasource
object Datasource1: TDataSource
DataSet = MemDataset1
left = 271
top = 108

View File

@ -5,7 +5,7 @@ unit Main;
interface
uses
ComCtrls, db, DBGrids, memds, Forms, TADbSource, TAGraph, TASeries;
ComCtrls, db, DBGrids, memds, Forms, TADbSource, TAGraph, TASeries, Classes;
type
@ -21,6 +21,7 @@ type
MemDataset1: TMemDataset;
ToolBar1: TToolBar;
tbCopy: TToolButton;
procedure FormCreate(Sender: TObject);
procedure tbCopyClick(Sender: TObject);
end;
@ -33,6 +34,24 @@ implementation
{ TForm1 }
{ Add dummy data to start with }
procedure TForm1.FormCreate(Sender: TObject);
const
N = 3;
var
i: Integer;
Fx, Fy: TField;
begin
Fx := MemDataset1.FieldByName('X');
Fy := MemDataset1.FieldByName('Y');
for i:= 1 to N do begin
MemDataset1.Append;
Fx.AsInteger := i;
Fy.AsFloat := Random;
MemDataset1.Post;
end;
end;
procedure TForm1.tbCopyClick(Sender: TObject);
begin
Chart1BarSeries1.ListSource.CopyFrom(DbChartSource1);