diff --git a/.gitattributes b/.gitattributes index da837a9af7..ddcaaaa524 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3745,6 +3745,10 @@ components/tachart/test/SourcesTest.pas svneol=native#text/pascal components/tachart/test/UtilsTest.pas svneol=native#text/pascal components/tachart/test/test.lpi svneol=native#text/plain components/tachart/test/test.lpr svneol=native#text/pascal +components/tachart/tutorials/background/backimage.lpi svneol=native#text/plain +components/tachart/tutorials/background/backimage.lpr svneol=native#text/plain +components/tachart/tutorials/background/main.lfm svneol=native#text/plain +components/tachart/tutorials/background/main.pas svneol=native#text/plain components/tachart/tutorials/bar_series/horizontal_bars/project1.lpi svneol=native#text/pascal components/tachart/tutorials/bar_series/horizontal_bars/project1.lpr svneol=native#text/pascal components/tachart/tutorials/bar_series/horizontal_bars/unit1.lfm svneol=native#text/pascal diff --git a/components/tachart/tutorials/background/backimage.lpi b/components/tachart/tutorials/background/backimage.lpi new file mode 100644 index 0000000000..efda23a4d9 --- /dev/null +++ b/components/tachart/tutorials/background/backimage.lpi @@ -0,0 +1,113 @@ + + + + + + + + + + <ResourceType Value="res"/> + <UseXPManifest Value="True"/> + </General> + <i18n> + <EnableI18N LFM="False"/> + </i18n> + <VersionInfo> + <StringTable ProductVersion=""/> + </VersionInfo> + <BuildModes Count="2"> + <Item1 Name="Debug" Default="True"/> + <Item2 Name="Release"> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="backimage"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + </SearchPaths> + <CodeGeneration> + <SmartLinkUnit Value="True"/> + </CodeGeneration> + <Linking> + <Debugging> + <StripSymbols Value="True"/> + </Debugging> + <LinkSmart Value="True"/> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + </CompilerOptions> + </Item2> + </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="backimage.lpr"/> + <IsPartOfProject Value="True"/> + <UnitName Value="backimage"/> + </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="11"/> + <PathDelim Value="\"/> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + </SearchPaths> + <CodeGeneration> + <SmartLinkUnit Value="True"/> + </CodeGeneration> + <Linking> + <Debugging> + <DebugInfoType Value="dsDwarf2Set"/> + </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> diff --git a/components/tachart/tutorials/background/backimage.lpr b/components/tachart/tutorials/background/backimage.lpr new file mode 100644 index 0000000000..a20f8bbb92 --- /dev/null +++ b/components/tachart/tutorials/background/backimage.lpr @@ -0,0 +1,21 @@ +program backimage; + +{$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(TForm1, Form1); + Application.Run; +end. + diff --git a/components/tachart/tutorials/background/main.lfm b/components/tachart/tutorials/background/main.lfm new file mode 100644 index 0000000000..7d2feb6d25 --- /dev/null +++ b/components/tachart/tutorials/background/main.lfm @@ -0,0 +1,76 @@ +object Form1: TForm1 + Left = 340 + Height = 300 + Top = 154 + Width = 400 + Caption = 'Form1' + ClientHeight = 300 + ClientWidth = 400 + OnCreate = FormCreate + OnDestroy = FormDestroy + LCLVersion = '1.3' + object Chart1: TChart + Left = 0 + Height = 300 + Top = 0 + Width = 400 + AxisList = < + item + Grid.Color = clSkyBlue + Grid.Visible = False + Marks.Format = '%.0n' + Marks.Style = smsCustom + Minors = <> + Title.LabelFont.Height = -16 + Title.LabelFont.Orientation = 900 + Title.LabelFont.Style = [fsBold] + Title.Visible = True + Title.Caption = 'Downloads per year' + end + item + Grid.Visible = False + Alignment = calBottom + Minors = <> + Title.LabelFont.Height = -16 + Title.LabelFont.Style = [fsBold] + Title.Visible = True + Title.Caption = 'Year' + end> + Foot.Brush.Color = clBtnFace + Foot.Font.Color = clBlue + Title.Brush.Color = clBtnFace + Title.Brush.Style = bsClear + Title.Font.Color = clNavy + Title.Font.Height = -17 + Title.Font.Style = [fsBold] + Title.Text.Strings = ( + 'Lazarus Downloads' + ) + Title.Visible = True + OnBeforeDrawBackground = Chart1BeforeDrawBackground + OnBeforeDrawBackWall = Chart1BeforeDrawBackWall + Align = alClient + ParentColor = False + object Chart1BarSeries1: TBarSeries + Shadow.Color = clNavy + Shadow.OffsetX = 4 + BarBrush.Color = clSkyBlue + Source = ListChartSource1 + end + end + object ListChartSource1: TListChartSource + DataPoints.Strings = ( + '2005|53299|?|' + '2006|119613|?|' + '2007|158060|?|' + '2008|218915|?|' + '2009|190567|?|' + '2010|230108|?|' + '2011|267858|?|' + '2012|298335|?|' + '2013|280586|?|' + ) + left = 120 + top = 56 + end +end diff --git a/components/tachart/tutorials/background/main.pas b/components/tachart/tutorials/background/main.pas new file mode 100644 index 0000000000..7e3a362796 --- /dev/null +++ b/components/tachart/tutorials/background/main.pas @@ -0,0 +1,73 @@ +unit main; +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, FileUtil, TAGraph, TASeries, TASources, Forms, Controls, + Graphics, Dialogs; + +type + + { TForm1 } + + TForm1 = class(TForm) + Chart1: TChart; + Chart1BarSeries1: TBarSeries; + ListChartSource1: TListChartSource; + procedure Chart1BeforeDrawBackground(ASender: TChart; ACanvas: TCanvas; + const ARect: TRect; var ADoDefaultDrawing: Boolean); + procedure Chart1BeforeDrawBackWall(ASender: TChart; ACanvas: TCanvas; + const ARect: TRect; var ADoDefaultDrawing: Boolean); + procedure FormCreate(Sender: TObject); + procedure FormDestroy(Sender: TObject); + private + { private declarations } + FBackImage: TPicture; + public + { public declarations } + end; + +var + Form1: TForm1; + +implementation + +{$R *.lfm} + +//{$R splash_logo.res} + +{ TForm1 } + +procedure TForm1.FormCreate(Sender: TObject); +begin + FBackImage := TPicture.Create; + FBackImage.LoadFromFile('..\..\..\..\images\splash_logo.png'); + // above path assumes standard Lazarus installation + + // or, use resources: + //FBackImage.LoadFromResourceName(HInstance, 'splash_logo'); + // Don't forget to active the "{$R" directive above. +end; + +procedure TForm1.Chart1BeforeDrawBackWall(ASender: TChart; ACanvas: TCanvas; + const ARect: TRect; var ADoDefaultDrawing: Boolean); +begin + ACanvas.StretchDraw(ARect, FBackImage.Graphic); + ADoDefaultDrawing := false; +end; + +procedure TForm1.Chart1BeforeDrawBackground(ASender: TChart; ACanvas: TCanvas; + const ARect: TRect; var ADoDefaultDrawing: Boolean); +begin + ACanvas.GradientFill(ARect, clSkyBlue, clWhite, gdVertical); + ADoDefaultDrawing := false; +end; + +procedure TForm1.FormDestroy(Sender: TObject); +begin + FBackImage.Free; +end; + +end. + diff --git a/components/tachart/tutorials/readme.txt b/components/tachart/tutorials/readme.txt index 4e3225b90a..52c5282fef 100644 --- a/components/tachart/tutorials/readme.txt +++ b/components/tachart/tutorials/readme.txt @@ -50,9 +50,24 @@ topics: -------------------------------------------------------------------------------- folder "bar_series" -------------------------------------------------------------------------------- -tutorial +tutorials http://wiki.lazarus.freepascal.org/TAChart_Tutorial:_BarSeries + http://wiki.lazarus.freepascal.org/TAChart_Tutorial:_Stacked_BarSeries topics - multiple bar series arranged side-by-side +- stacked bar series +- TChartStyle - TRandomChartSource + +-------------------------------------------------------------------------------- +folder "background" +-------------------------------------------------------------------------------- +tutorial + http://wiki.lazarus.freepascal.org/TAChart_Tutorial:_Background_design + +topics +- events used by TChart +- user-drawn chart backgrounds: entire background, chart area ("back wall") only +- transparency of bar series +- enter data at design-time