mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-03 05:58:14 +02:00
TAChart: Add html demo.
git-svn-id: trunk@55444 -
This commit is contained in:
parent
60dfbebc9c
commit
eff0b46426
4
.gitattributes
vendored
4
.gitattributes
vendored
@ -4345,6 +4345,10 @@ components/tachart/demo/func/funcdemo.lpi svneol=native#text/plain
|
||||
components/tachart/demo/func/funcdemo.lpr svneol=native#text/plain
|
||||
components/tachart/demo/func/main.lfm svneol=native#text/plain
|
||||
components/tachart/demo/func/main.pas svneol=native#text/plain
|
||||
components/tachart/demo/html/htmldemo.lpi svneol=native#text/plain
|
||||
components/tachart/demo/html/htmldemo.lpr svneol=native#text/plain
|
||||
components/tachart/demo/html/main.lfm svneol=native#text/plain
|
||||
components/tachart/demo/html/main.pas svneol=native#text/plain
|
||||
components/tachart/demo/imagelist/Main.lfm svneol=native#text/plain
|
||||
components/tachart/demo/imagelist/Main.pas svneol=native#text/pascal
|
||||
components/tachart/demo/imagelist/imagelistdemo.lpi svneol=native#text/plain
|
||||
|
81
components/tachart/demo/html/htmldemo.lpi
Normal file
81
components/tachart/demo/html/htmldemo.lpi
Normal file
@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="10"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="htmldemo"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="TAChartLazarusPkg"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="htmldemo.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="main.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="MainForm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="htmldemo"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<UseExternalDbgSyms Value="True"/>
|
||||
</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>
|
21
components/tachart/demo/html/htmldemo.lpr
Normal file
21
components/tachart/demo/html/htmldemo.lpr
Normal file
@ -0,0 +1,21 @@
|
||||
program htmldemo;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, main, tachartlazaruspkg
|
||||
{ you can add units after this };
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
RequireDerivedFormResource := True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TMainForm, MainForm);
|
||||
Application.Run;
|
||||
end.
|
||||
|
193
components/tachart/demo/html/main.lfm
Normal file
193
components/tachart/demo/html/main.lfm
Normal file
@ -0,0 +1,193 @@
|
||||
object MainForm: TMainForm
|
||||
Left = 280
|
||||
Height = 432
|
||||
Top = 130
|
||||
Width = 655
|
||||
Caption = 'HTML demo'
|
||||
ClientHeight = 432
|
||||
ClientWidth = 655
|
||||
OnCreate = FormCreate
|
||||
LCLVersion = '1.9.0.0'
|
||||
object BottomPanel: TPanel
|
||||
Left = 8
|
||||
Height = 91
|
||||
Top = 333
|
||||
Width = 647
|
||||
Align = alBottom
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 91
|
||||
ClientWidth = 647
|
||||
TabOrder = 0
|
||||
object CgHTML: TCheckGroup
|
||||
Left = 0
|
||||
Height = 78
|
||||
Top = 8
|
||||
Width = 221
|
||||
AutoFill = True
|
||||
AutoSize = True
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'HTML'
|
||||
ChildSizing.LeftRightSpacing = 6
|
||||
ChildSizing.TopBottomSpacing = 6
|
||||
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
|
||||
ChildSizing.EnlargeVertical = crsHomogenousChildResize
|
||||
ChildSizing.ShrinkHorizontal = crsScaleChilds
|
||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||
ChildSizing.ControlsPerLine = 3
|
||||
ClientHeight = 58
|
||||
ClientWidth = 217
|
||||
Columns = 3
|
||||
Items.Strings = (
|
||||
'title'
|
||||
'footer'
|
||||
'legend'
|
||||
'x axis title'
|
||||
'y axis title'
|
||||
)
|
||||
OnItemClick = CgHTMLItemClick
|
||||
TabOrder = 0
|
||||
Data = {
|
||||
050000000202020202
|
||||
}
|
||||
end
|
||||
object Button1: TButton
|
||||
AnchorSideTop.Control = BottomPanel
|
||||
AnchorSideRight.Control = BottomPanel
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 518
|
||||
Height = 25
|
||||
Top = 8
|
||||
Width = 121
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
Caption = 'Copy to clipboard'
|
||||
OnClick = Button1Click
|
||||
TabOrder = 1
|
||||
end
|
||||
object Button2: TButton
|
||||
AnchorSideLeft.Control = Button1
|
||||
AnchorSideTop.Control = Button1
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Button1
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 518
|
||||
Height = 25
|
||||
Top = 37
|
||||
Width = 121
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 4
|
||||
Caption = 'Save to WMF'
|
||||
OnClick = Button2Click
|
||||
TabOrder = 2
|
||||
end
|
||||
object Button3: TButton
|
||||
AnchorSideLeft.Control = Button1
|
||||
AnchorSideTop.Control = Button2
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Button1
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 518
|
||||
Height = 25
|
||||
Top = 66
|
||||
Width = 121
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 4
|
||||
Caption = 'Save to SVG'
|
||||
OnClick = Button3Click
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
||||
object Chart: TChart
|
||||
Left = 8
|
||||
Height = 317
|
||||
Top = 8
|
||||
Width = 639
|
||||
AxisList = <
|
||||
item
|
||||
Grid.Color = clSilver
|
||||
Grid.Style = psSolid
|
||||
Minors = <>
|
||||
Title.LabelFont.Height = -16
|
||||
Title.LabelFont.Orientation = 900
|
||||
Title.Visible = True
|
||||
Title.Caption = 'Area, cm<sup>2</cm>'
|
||||
Title.TextFormat = tfHTML
|
||||
end
|
||||
item
|
||||
Grid.Color = clSilver
|
||||
Grid.Style = psSolid
|
||||
Grid.Visible = False
|
||||
Alignment = calBottom
|
||||
Minors = <>
|
||||
Title.LabelFont.Height = -16
|
||||
Title.Visible = True
|
||||
Title.Caption = 'Angle α'
|
||||
Title.TextFormat = tfHTML
|
||||
end>
|
||||
BackColor = clWhite
|
||||
Foot.Alignment = taLeftJustify
|
||||
Foot.Brush.Color = clBtnFace
|
||||
Foot.Brush.Style = bsClear
|
||||
Foot.Font.Color = clBlue
|
||||
Foot.Text.Strings = (
|
||||
'<u>Reference</u>:'
|
||||
'W. Shakespeare, <i>"J. Non-reproducible Results"</i>, <b>38</b>, 512 (2017)'
|
||||
)
|
||||
Foot.TextFormat = tfHTML
|
||||
Foot.Visible = True
|
||||
Legend.TextFormat = tfHTML
|
||||
Legend.Visible = True
|
||||
Title.Brush.Color = clBtnFace
|
||||
Title.Brush.Style = bsClear
|
||||
Title.Font.Color = clBlue
|
||||
Title.Font.Height = -19
|
||||
Title.Font.Style = [fsBold]
|
||||
Title.Text.Strings = (
|
||||
'Plot of area (cm<sup>2</sup>) <i>vs.</i> angle α'
|
||||
)
|
||||
Title.TextFormat = tfHTML
|
||||
Title.Visible = True
|
||||
Align = alClient
|
||||
BorderSpacing.Around = 8
|
||||
Color = clWhite
|
||||
object RedSeries: TLineSeries
|
||||
Title = '<font color="red">Red</font> series'
|
||||
LinePen.Color = clRed
|
||||
Source = RedSource
|
||||
end
|
||||
object BlueSeries: TLineSeries
|
||||
Title = '<font color="blue">Blue</font> series'
|
||||
LinePen.Color = clBlue
|
||||
Source = BlueSource
|
||||
end
|
||||
end
|
||||
object RedSource: TRandomChartSource
|
||||
PointsNumber = 20
|
||||
RandSeed = 1926906778
|
||||
XMax = 90
|
||||
XMin = 0
|
||||
YMax = 10
|
||||
YMin = 4
|
||||
left = 121
|
||||
top = 52
|
||||
end
|
||||
object BlueSource: TRandomChartSource
|
||||
PointsNumber = 30
|
||||
RandSeed = 1926958054
|
||||
XMax = 90
|
||||
XMin = 0
|
||||
YMax = 8
|
||||
YMin = 0
|
||||
left = 120
|
||||
top = 111
|
||||
end
|
||||
end
|
91
components/tachart/demo/html/main.pas
Normal file
91
components/tachart/demo/html/main.pas
Normal file
@ -0,0 +1,91 @@
|
||||
unit main;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, TAGraph, TASeries, TASources, Forms, Controls,
|
||||
Graphics, Dialogs, ExtCtrls, StdCtrls;
|
||||
|
||||
type
|
||||
|
||||
{ TMainForm }
|
||||
|
||||
TMainForm = class(TForm)
|
||||
Button1: TButton;
|
||||
Button2: TButton;
|
||||
Button3: TButton;
|
||||
Chart: TChart;
|
||||
CgHTML: TCheckGroup;
|
||||
RedSource: TRandomChartSource;
|
||||
BlueSource: TRandomChartSource;
|
||||
RedSeries: TLineSeries;
|
||||
BlueSeries: TLineSeries;
|
||||
BottomPanel: TPanel;
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure Button2Click(Sender: TObject);
|
||||
procedure Button3Click(Sender: TObject);
|
||||
procedure CgHTMLItemClick(Sender: TObject; Index: integer);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
private
|
||||
|
||||
public
|
||||
|
||||
end;
|
||||
|
||||
var
|
||||
MainForm: TMainForm;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
TAChartUtils, TADrawerWMF, TADrawerSVG;
|
||||
|
||||
{ TMainForm }
|
||||
|
||||
procedure TMainForm.Button1Click(Sender: TObject);
|
||||
begin
|
||||
Chart.CopyToClipboardBitmap;
|
||||
end;
|
||||
|
||||
procedure TMainForm.Button2Click(Sender: TObject);
|
||||
begin
|
||||
with Chart do
|
||||
Draw(TWindowsMetafileDrawer.Create('test.wmf'), Rect(0, 0, Width, Height));
|
||||
ShowMessage('Chart saved to file "test.wmf"');
|
||||
end;
|
||||
|
||||
procedure TMainForm.Button3Click(Sender: TObject);
|
||||
begin
|
||||
Chart.SaveToSVGFile('test.svg');
|
||||
ShowMessage('Chart saved to file "test.svg"');
|
||||
end;
|
||||
|
||||
procedure TMainForm.CgHTMLItemClick(Sender: TObject; Index: integer);
|
||||
var
|
||||
tf: TChartTextFormat;
|
||||
begin
|
||||
if CgHTML.Checked[Index] then tf := tfHTML else tf := tfNormal;
|
||||
case Index of
|
||||
0: Chart.Title.TextFormat := tf;
|
||||
1: Chart.Foot.TextFormat := tf;
|
||||
2: Chart.Legend.TextFormat := tf;
|
||||
3: Chart.BottomAxis.Title.TextFormat := tf;
|
||||
4: Chart.LeftAxis.Title.TextFormat := tf;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
CgHTML.Checked[0] := Chart.Title.TextFormat = tfHTML;
|
||||
CgHTML.Checked[1] := Chart.Foot.TextFormat = tfHTML;
|
||||
CgHTML.Checked[2] := Chart.Legend.TextFormat = tfHTML;
|
||||
CgHTML.Checked[3] := Chart.BottomAxis.Title.TextFormat = tfHTML;
|
||||
CgHTML.Checked[4] := Chart.LeftAxis.Title.TextFormat = tfHTML;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user