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