mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-18 05:20:12 +02:00
TAChart: Add SVG export option to the save demo
git-svn-id: trunk@30207 -
This commit is contained in:
parent
69326eb314
commit
092814ada0
@ -1,18 +1,18 @@
|
|||||||
object Form1: TForm1
|
object Form1: TForm1
|
||||||
Left = 318
|
Left = 318
|
||||||
Height = 300
|
Height = 299
|
||||||
Top = 151
|
Top = 151
|
||||||
Width = 421
|
Width = 538
|
||||||
Caption = 'Form1'
|
Caption = 'Form1'
|
||||||
ClientHeight = 300
|
ClientHeight = 299
|
||||||
ClientWidth = 421
|
ClientWidth = 538
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
LCLVersion = '0.9.31'
|
LCLVersion = '0.9.31'
|
||||||
object Chart1: TChart
|
object Chart1: TChart
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 276
|
Height = 275
|
||||||
Top = 24
|
Top = 24
|
||||||
Width = 421
|
Width = 538
|
||||||
AxisList = <
|
AxisList = <
|
||||||
item
|
item
|
||||||
Title.LabelFont.Orientation = 900
|
Title.LabelFont.Orientation = 900
|
||||||
@ -45,7 +45,7 @@ object Form1: TForm1
|
|||||||
Left = 0
|
Left = 0
|
||||||
Height = 24
|
Height = 24
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 421
|
Width = 538
|
||||||
ButtonWidth = 100
|
ButtonWidth = 100
|
||||||
Caption = 'ToolBar1'
|
Caption = 'ToolBar1'
|
||||||
Flat = False
|
Flat = False
|
||||||
@ -64,7 +64,7 @@ object Form1: TForm1
|
|||||||
OnClick = tbSaveAsPNGClick
|
OnClick = tbSaveAsPNGClick
|
||||||
end
|
end
|
||||||
object tbCopyToClipboard: TToolButton
|
object tbCopyToClipboard: TToolButton
|
||||||
Left = 301
|
Left = 401
|
||||||
Top = 2
|
Top = 2
|
||||||
Caption = 'Copy to clipboard'
|
Caption = 'Copy to clipboard'
|
||||||
OnClick = tbCopyToClipboardClick
|
OnClick = tbCopyToClipboardClick
|
||||||
@ -75,6 +75,12 @@ object Form1: TForm1
|
|||||||
Caption = 'Save as JPEG'
|
Caption = 'Save as JPEG'
|
||||||
OnClick = tbSaveAsJPEGClick
|
OnClick = tbSaveAsJPEGClick
|
||||||
end
|
end
|
||||||
|
object tbSaveAsSVG: TToolButton
|
||||||
|
Left = 301
|
||||||
|
Top = 2
|
||||||
|
Caption = 'Save as SVG'
|
||||||
|
OnClick = tbSaveAsSVGClick
|
||||||
|
end
|
||||||
end
|
end
|
||||||
object SaveDialog1: TSaveDialog
|
object SaveDialog1: TSaveDialog
|
||||||
left = 64
|
left = 64
|
||||||
|
@ -5,7 +5,7 @@ unit main;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
SysUtils, Forms, Graphics, Dialogs, ComCtrls, TAGraph, TASeries, TAFuncSeries;
|
SysUtils, Forms, Graphics, Dialogs, ComCtrls, TAGraph, TASeries, TAFuncSeries, Classes;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -21,12 +21,14 @@ type
|
|||||||
tbSaveAsPNG: TToolButton;
|
tbSaveAsPNG: TToolButton;
|
||||||
tbCopyToClipboard: TToolButton;
|
tbCopyToClipboard: TToolButton;
|
||||||
tbSaveAsJPEG: TToolButton;
|
tbSaveAsJPEG: TToolButton;
|
||||||
|
tbSaveAsSVG: TToolButton;
|
||||||
procedure Chart1FuncSeries1Calculate(const AX: Double; out AY: Double);
|
procedure Chart1FuncSeries1Calculate(const AX: Double; out AY: Double);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure tbCopyToClipboardClick(Sender: TObject);
|
procedure tbCopyToClipboardClick(Sender: TObject);
|
||||||
procedure tbSaveAsBMPClick(Sender: TObject);
|
procedure tbSaveAsBMPClick(Sender: TObject);
|
||||||
procedure tbSaveAsJPEGClick(Sender: TObject);
|
procedure tbSaveAsJPEGClick(Sender: TObject);
|
||||||
procedure tbSaveAsPNGClick(Sender: TObject);
|
procedure tbSaveAsPNGClick(Sender: TObject);
|
||||||
|
procedure tbSaveAsSVGClick(Sender: TObject);
|
||||||
private
|
private
|
||||||
function GetFileName(const AExt: String): String;
|
function GetFileName(const AExt: String): String;
|
||||||
end;
|
end;
|
||||||
@ -38,6 +40,9 @@ implementation
|
|||||||
|
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
|
uses
|
||||||
|
TADrawerSVG, TADrawUtils, TADrawerCanvas;
|
||||||
|
|
||||||
{ TForm1 }
|
{ TForm1 }
|
||||||
|
|
||||||
procedure TForm1.Chart1FuncSeries1Calculate(const AX: Double; out AY: Double);
|
procedure TForm1.Chart1FuncSeries1Calculate(const AX: Double; out AY: Double);
|
||||||
@ -85,5 +90,21 @@ begin
|
|||||||
Chart1.SaveToFile(TPortableNetworkGraphic, GetFileName('png'));
|
Chart1.SaveToFile(TPortableNetworkGraphic, GetFileName('png'));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.tbSaveAsSVGClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
fs: TFileStream;
|
||||||
|
id: IChartDrawer;
|
||||||
|
begin
|
||||||
|
fs := TFileStream.Create(GetFileName('svg'), fmCreate);
|
||||||
|
try
|
||||||
|
id := TSVGDrawer.Create(fs, true);
|
||||||
|
id.DoChartColorToFPColor := @ChartColorSysToFPColor;
|
||||||
|
with Chart1 do
|
||||||
|
Draw(id, Rect(0, 0, Width, Height));
|
||||||
|
finally
|
||||||
|
fs.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<CONFIG>
|
<CONFIG>
|
||||||
<ProjectOptions>
|
<ProjectOptions>
|
||||||
|
<Version Value="9"/>
|
||||||
<PathDelim Value="\"/>
|
<PathDelim Value="\"/>
|
||||||
<Version Value="8"/>
|
|
||||||
<General>
|
<General>
|
||||||
<Flags>
|
<Flags>
|
||||||
<SaveClosedFiles Value="False"/>
|
<SaveClosedFiles Value="False"/>
|
||||||
@ -10,13 +10,15 @@
|
|||||||
</Flags>
|
</Flags>
|
||||||
<SessionStorage Value="InProjectDir"/>
|
<SessionStorage Value="InProjectDir"/>
|
||||||
<MainUnit Value="0"/>
|
<MainUnit Value="0"/>
|
||||||
<TargetFileExt Value=".exe"/>
|
|
||||||
<Title Value="Saving chart as image demo"/>
|
<Title Value="Saving chart as image demo"/>
|
||||||
<ResourceType Value="res"/>
|
<ResourceType Value="res"/>
|
||||||
</General>
|
</General>
|
||||||
<VersionInfo>
|
<VersionInfo>
|
||||||
<StringTable Comments="" CompanyName="" FileDescription="" FileVersion="0.0.0.0" InternalName="" LegalCopyright="" LegalTrademarks="" OriginalFilename="" ProductName="" ProductVersion=""/>
|
<StringTable ProductVersion=""/>
|
||||||
</VersionInfo>
|
</VersionInfo>
|
||||||
|
<BuildModes Count="1">
|
||||||
|
<Item1 Name="default" Default="True"/>
|
||||||
|
</BuildModes>
|
||||||
<PublishOptions>
|
<PublishOptions>
|
||||||
<Version Value="2"/>
|
<Version Value="2"/>
|
||||||
<IgnoreBinaries Value="False"/>
|
<IgnoreBinaries Value="False"/>
|
||||||
@ -29,14 +31,18 @@
|
|||||||
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||||
</local>
|
</local>
|
||||||
</RunParams>
|
</RunParams>
|
||||||
<RequiredPackages Count="2">
|
<RequiredPackages Count="3">
|
||||||
<Item1>
|
<Item1>
|
||||||
<PackageName Value="TAChartLazarusPkg"/>
|
<PackageName Value="LCLBase"/>
|
||||||
<MinVersion Major="1" Valid="True"/>
|
<MinVersion Major="1" Release="1" Valid="True"/>
|
||||||
</Item1>
|
</Item1>
|
||||||
<Item2>
|
<Item2>
|
||||||
<PackageName Value="LCL"/>
|
<PackageName Value="TAChartLazarusPkg"/>
|
||||||
|
<MinVersion Major="1" Valid="True"/>
|
||||||
</Item2>
|
</Item2>
|
||||||
|
<Item3>
|
||||||
|
<PackageName Value="LCL"/>
|
||||||
|
</Item3>
|
||||||
</RequiredPackages>
|
</RequiredPackages>
|
||||||
<Units Count="2">
|
<Units Count="2">
|
||||||
<Unit0>
|
<Unit0>
|
||||||
@ -54,12 +60,11 @@
|
|||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
<Version Value="9"/>
|
<Version Value="10"/>
|
||||||
<PathDelim Value="\"/>
|
<PathDelim Value="\"/>
|
||||||
<SearchPaths>
|
<SearchPaths>
|
||||||
<IncludeFiles Value="$(ProjOutDir)\"/>
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||||
<LCLWidgetType Value="win32"/>
|
|
||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
<Parsing>
|
<Parsing>
|
||||||
<SyntaxOptions>
|
<SyntaxOptions>
|
||||||
|
Loading…
Reference in New Issue
Block a user