TAChart: Add demo for TChartLiveView.

git-svn-id: trunk@63763 -
This commit is contained in:
wp 2020-08-16 17:06:43 +00:00
parent 14ce141c40
commit 3ea304cd6e
5 changed files with 417 additions and 0 deletions

4
.gitattributes vendored
View File

@ -5250,6 +5250,10 @@ components/tachart/demo/listbox/Unit1.lfm svneol=native#text/plain
components/tachart/demo/listbox/Unit1.pas svneol=native#text/pascal
components/tachart/demo/listbox/listboxdemo.lpi svneol=native#text/plain
components/tachart/demo/listbox/listboxdemo.lpr svneol=native#text/pascal
components/tachart/demo/liveview/liveviewdemo.lpi svneol=native#text/xml
components/tachart/demo/liveview/liveviewdemo.lpr svneol=native#text/pascal
components/tachart/demo/liveview/main.lfm svneol=native#text/plain
components/tachart/demo/liveview/main.pas svneol=native#text/pascal
components/tachart/demo/manhattan/Main.lfm svneol=native#text/plain
components/tachart/demo/manhattan/Main.pas svneol=native#text/pascal
components/tachart/demo/manhattan/manhattandemo.lpi svneol=native#text/plain

View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="12"/>
<PathDelim Value="\"/>
<General>
<Flags>
<CompatibilityMode Value="True"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<Title Value="liveviewdemo"/>
<Scaled Value="True"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<XPManifest>
<DpiAware Value="True"/>
</XPManifest>
<Icon Value="0"/>
</General>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
<UseFileFilters Value="True"/>
</PublishOptions>
<RunParams>
<FormatVersion Value="2"/>
</RunParams>
<RequiredPackages Count="2">
<Item1>
<PackageName Value="TAChartLazarusPkg"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="liveviewdemo.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="main.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="MainFrom"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="liveviewdemo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,25 @@
program liveviewdemo;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
{$IFDEF HASAMIGA}
athreads,
{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, main, tachartlazaruspkg
{ you can add units after this };
{$R *.res}
begin
RequireDerivedFormResource:=True;
Application.Scaled:=True;
Application.Initialize;
Application.CreateForm(TMainFrom, MainFrom);
Application.Run;
end.

View File

@ -0,0 +1,197 @@
object MainFrom: TMainFrom
Left = 299
Height = 446
Top = 130
Width = 723
Caption = 'Live View Demo'
ClientHeight = 446
ClientWidth = 723
OnCreate = FormCreate
LCLVersion = '2.1.0.0'
object Chart1: TChart
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ChartNavScrollBar1
Left = 0
Height = 392
Top = 0
Width = 723
AxisList = <
item
Grid.Color = clSilver
Intervals.MaxLength = 80
Intervals.MinLength = 30
Marks.LabelBrush.Style = bsClear
Minors = <>
Title.LabelFont.Orientation = 900
Title.LabelBrush.Style = bsClear
end
item
Grid.Color = clSilver
Intervals.MaxLength = 80
Intervals.MinLength = 30
Alignment = calBottom
Marks.LabelBrush.Style = bsClear
Minors = <>
Title.LabelBrush.Style = bsClear
end>
BackColor = clWhite
Foot.Brush.Color = clBtnFace
Foot.Font.Color = clBlue
Title.Brush.Color = clBtnFace
Title.Font.Color = clBlue
Title.Text.Strings = (
'TAChart'
)
Anchors = [akTop, akLeft, akRight, akBottom]
object Chart1LineSeries1: TLineSeries
end
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Chart1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 37
Top = 409
Width = 723
Anchors = [akLeft, akRight, akBottom]
BevelOuter = bvNone
ClientHeight = 37
ClientWidth = 723
TabOrder = 2
object btnAddDataPoint: TButton
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 6
Height = 25
Top = 6
Width = 105
AutoSize = True
BorderSpacing.Around = 6
Caption = 'Add data point'
OnClick = btnAddDataPointClick
TabOrder = 0
end
object cbLiveMode: TCheckBox
AnchorSideLeft.Control = btnAddDataPoint
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrCenter
Left = 135
Height = 19
Top = 9
Width = 75
BorderSpacing.Left = 24
Caption = 'Live mode'
Checked = True
OnChange = cbLiveModeChange
State = cbChecked
TabOrder = 1
end
object lblViewportSize: TLabel
AnchorSideLeft.Control = cbLiveMode
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrCenter
Left = 234
Height = 15
Top = 11
Width = 69
BorderSpacing.Left = 24
Caption = 'Viewport size'
ParentColor = False
Visible = False
end
object seViewportSize: TFloatSpinEdit
AnchorSideLeft.Control = lblViewportSize
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrCenter
Left = 311
Height = 23
Top = 7
Width = 73
Alignment = taRightJustify
BorderSpacing.Left = 8
MaxValue = 0
OnChange = seViewportSizeChange
TabOrder = 2
Value = 5
Visible = False
end
object cbExtentY: TComboBox
AnchorSideLeft.Control = lblExtentY
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrCenter
Left = 456
Height = 23
Top = 7
Width = 100
BorderSpacing.Left = 8
ItemHeight = 15
ItemIndex = 0
Items.Strings = (
'Auto'
'Full'
'Logical'
)
OnChange = cbExtentYChange
TabOrder = 3
Text = 'Auto'
end
object cbFixedExtent: TCheckBox
AnchorSideLeft.Control = cbExtentY
AnchorSideLeft.Side = asrBottom
Left = 580
Height = 19
Top = 9
Width = 127
BorderSpacing.Left = 24
Caption = 'y = -1.5 .. .+1.5 fixed'
OnChange = cbFixedExtentChange
TabOrder = 4
end
object lblExtentY: TLabel
AnchorSideLeft.Control = seViewportSize
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrCenter
Left = 408
Height = 15
Top = 11
Width = 40
BorderSpacing.Left = 24
Caption = 'ExtentY'
ParentColor = False
end
end
object ChartNavScrollBar1: TChartNavScrollBar
AnchorSideLeft.Control = Chart1
AnchorSideRight.Control = Chart1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel1
Left = 0
Height = 17
Top = 392
Width = 723
AutoPageSize = True
Chart = Chart1
Anchors = [akLeft, akRight, akBottom]
PageSize = 0
TabOrder = 1
end
object ChartLiveView1: TChartLiveView
Chart = Chart1
ViewportSize = 5
Left = 308
Top = 143
end
end

View File

@ -0,0 +1,105 @@
unit main;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
Spin, TAGraph, TASeries, TANavigation, TAChartLiveView;
type
{ TMainFrom }
TMainFrom = class(TForm)
btnAddDataPoint: TButton;
Chart1: TChart;
Chart1LineSeries1: TLineSeries;
ChartLiveView1: TChartLiveView;
ChartNavScrollBar1: TChartNavScrollBar;
cbLiveMode: TCheckBox;
cbFixedExtent: TCheckBox;
cbExtentY: TComboBox;
lblExtentY: TLabel;
seViewportSize: TFloatSpinEdit;
lblViewportSize: TLabel;
Panel1: TPanel;
procedure btnAddDataPointClick(Sender: TObject);
procedure cbLiveModeChange(Sender: TObject);
procedure cbFixedExtentChange(Sender: TObject);
procedure cbExtentYChange(Sender: TObject);
procedure seViewportSizeChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
public
end;
var
MainFrom: TMainFrom;
implementation
{$R *.lfm}
uses
Math, TAChartUtils;
{ TMainFrom }
procedure TMainFrom.btnAddDataPointClick(Sender: TObject);
const
TWO_PI = 2.0 * pi;
var
x, y: Double;
begin
x := Chart1LineSeries1.Count;
y := sin(x * TWO_PI / 10) + randg(0, 0.1);
Chart1Lineseries1.AddXY(x, y);
end;
procedure TMainFrom.cbFixedExtentChange(Sender: TObject);
begin
Chart1.Extent.YMin := -1.5;
Chart1.Extent.YMax := 1.5;
Chart1.Extent.UseYMin := cbFixedExtent.Checked;
Chart1.Extent.UseYMax := cbFixedExtent.Checked;
end;
procedure TMainFrom.cbLiveModeChange(Sender: TObject);
begin
ChartLiveView1.Active := cbLiveMode.Checked;
seViewportSize.Visible := cbLiveMode.Checked;
lblViewportSize.Visible := cbLiveMode.Checked;
cbExtentY.Visible := cbLiveMode.Checked;
lblExtentY.Visible := cbLiveMode.Checked;
end;
procedure TMainFrom.cbExtentYChange(Sender: TObject);
begin
ChartLiveView1.ExtentY := TChartLiveViewExtentY(cbExtentY.ItemIndex);
end;
procedure TMainFrom.FormCreate(Sender: TObject);
begin
// Add three data points to start with
btnAddDataPointClick(nil);
btnAddDataPointClick(nil);
btnAddDataPointClick(nil);
// Initialize live view controls
cbLiveMode.Checked := ChartLiveView1.Active;
seViewportSize.Value := ChartLiveView1.ViewportSize;
cbExtentY.ItemIndex := ord(ChartLiveView1.ExtentY);
end;
procedure TMainFrom.seViewportSizeChange(Sender: TObject);
begin
ChartLiveView1.ViewportSize := seViewportSize.Value;
end;
end.