diff --git a/components/fpspreadsheet/examples/other/chart/scatter_log_write_demo.lpi b/components/fpspreadsheet/examples/other/chart/scatter_log_write_demo.lpi new file mode 100644 index 000000000..f38297720 --- /dev/null +++ b/components/fpspreadsheet/examples/other/chart/scatter_log_write_demo.lpi @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + <UseAppBundle Value="False"/> + <ResourceType Value="res"/> + </General> + <BuildModes> + <Item Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + <UseFileFilters Value="True"/> + </PublishOptions> + <RunParams> + <FormatVersion Value="2"/> + </RunParams> + <RequiredPackages> + <Item> + <PackageName Value="laz_fpspreadsheet"/> + </Item> + </RequiredPackages> + <Units> + <Unit> + <Filename Value="scatter_log_write_demo.lpr"/> + <IsPartOfProject Value="True"/> + </Unit> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="scatter_log_write_demo"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <Debugging> + <DebugInfoType Value="dsDwarf3"/> + </Debugging> + </Linking> + <Other> + <ConfigFile> + <WriteConfigFilePath Value=""/> + </ConfigFile> + </Other> + </CompilerOptions> + <Debugging> + <Exceptions> + <Item> + <Name Value="EAbort"/> + </Item> + <Item> + <Name Value="ECodetoolError"/> + </Item> + <Item> + <Name Value="EFOpenError"/> + </Item> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/components/fpspreadsheet/examples/other/chart/scatter_log_write_demo.lpr b/components/fpspreadsheet/examples/other/chart/scatter_log_write_demo.lpr new file mode 100644 index 000000000..a09505097 --- /dev/null +++ b/components/fpspreadsheet/examples/other/chart/scatter_log_write_demo.lpr @@ -0,0 +1,65 @@ +program scatter_log_write_demo; + +{$mode objfpc}{$H+} + +uses + SysUtils, + fpspreadsheet, fpstypes, fpsUtils, fpschart, xlsxooxml, fpsopendocument; + +const + FILE_NAME = 'scatter_log'; +var + book: TsWorkbook; + sheet: TsWorksheet; + ch: TsChart; + ser: TsScatterSeries; +begin + book := TsWorkbook.Create; + try + // Worksheet + sheet := book.AddWorksheet('test'); + + // Enter data + sheet.WriteText(0, 0, 'Data'); + sheet.WriteFont(0, 0, '', 12, [fssBold], scBlack); + sheet.WriteText (2, 0, 'x'); sheet.Writetext (2, 1, 'y'); + sheet.WriteNumber(3, 0, 0.1); sheet.WriteFormula(3, 1, 'exp(A4)'); + sheet.WriteNumber(4, 0, 0.8); sheet.WriteFormula(4, 1, 'exp(A5)'); + sheet.WriteNumber(5, 0, 1.4); sheet.WriteFormula(5, 1, 'exp(A6)'); + sheet.WriteNumber(6, 0, 2.6); sheet.WriteFormula(6, 1, 'exp(A7)'); + sheet.WriteNumber(7, 0, 4.3); sheet.WriteFormula(7, 1, 'exp(A8)'); + sheet.WriteNumber(8, 0, 5.9); sheet.WriteFormula(8, 1, 'exp(A9)'); + sheet.WriteNumber(9, 0, 7.5); sheet.WriteFormula(9, 1, 'exp(A10)'); + + // Create chart: left/top in cell D4, 150 mm x 100 mm + ch := book.AddChart(sheet, 2, 3, 150, 100); + + // Chart properties + ch.Border.Style := clsNoLine; + ch.Legend.Border.Style := clsNoLine; + ch.YAxis.Logarithmic := true; + + // Add scatter series + ser := TsScatterSeries.Create(ch); + + // Series properties + ser.SetTitleAddr(0, 0); + ser.SetXRange(3, 0, 9, 0); + ser.SetYRange(3, 1, 9, 1); + ser.ShowLines := true; + ser.ShowSymbols := true; + ser.Symbol := cssCircle; + + { + book.WriteToFile(FILE_NAME + '.xlsx', true); // Excel fails to open the file + WriteLn('Data saved with chart to ', FILE_NAME, '.xlsx'); + } + + book.Options := book.Options + [boCalcBeforeSaving]; + book.WriteToFile(FILE_NAME + '.ods', true); + WriteLn('Data saved with chart to ', FILE_NAME, '.ods'); + finally + book.Free; + end; +end. + diff --git a/components/fpspreadsheet/examples/other/chart/scatter_loglog_write_demo.lpi b/components/fpspreadsheet/examples/other/chart/scatter_loglog_write_demo.lpi new file mode 100644 index 000000000..cbd82f203 --- /dev/null +++ b/components/fpspreadsheet/examples/other/chart/scatter_loglog_write_demo.lpi @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="UTF-8"?> +<CONFIG> + <ProjectOptions> + <Version Value="12"/> + <PathDelim Value="\"/> + <General> + <Flags> + <MainUnitHasCreateFormStatements Value="False"/> + <MainUnitHasTitleStatement Value="False"/> + <MainUnitHasScaledStatement Value="False"/> + </Flags> + <SessionStorage Value="InProjectDir"/> + <Title Value="scatter_loglog_write_demo"/> + <UseAppBundle Value="False"/> + <ResourceType Value="res"/> + </General> + <BuildModes> + <Item Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + <UseFileFilters Value="True"/> + </PublishOptions> + <RunParams> + <FormatVersion Value="2"/> + </RunParams> + <RequiredPackages> + <Item> + <PackageName Value="laz_fpspreadsheet"/> + </Item> + </RequiredPackages> + <Units> + <Unit> + <Filename Value="scatter_loglog_write_demo.lpr"/> + <IsPartOfProject Value="True"/> + </Unit> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="scatter_loglog_write_demo"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <Debugging> + <DebugInfoType Value="dsDwarf3"/> + </Debugging> + </Linking> + <Other> + <ConfigFile> + <WriteConfigFilePath Value=""/> + </ConfigFile> + </Other> + </CompilerOptions> + <Debugging> + <Exceptions> + <Item> + <Name Value="EAbort"/> + </Item> + <Item> + <Name Value="ECodetoolError"/> + </Item> + <Item> + <Name Value="EFOpenError"/> + </Item> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/components/fpspreadsheet/examples/other/chart/scatter_loglog_write_demo.lpr b/components/fpspreadsheet/examples/other/chart/scatter_loglog_write_demo.lpr new file mode 100644 index 000000000..83c69baa3 --- /dev/null +++ b/components/fpspreadsheet/examples/other/chart/scatter_loglog_write_demo.lpr @@ -0,0 +1,67 @@ +program scatter_loglog_write_demo; + +{$mode objfpc}{$H+} + +uses + SysUtils, + fpspreadsheet, fpstypes, fpsUtils, fpschart, xlsxooxml, fpsopendocument; + +const + FILE_NAME = 'scatter_loglog'; +var + book: TsWorkbook; + sheet: TsWorksheet; + ch: TsChart; + ser: TsScatterSeries; +begin + book := TsWorkbook.Create; + try + // Worksheet + sheet := book.AddWorksheet('test'); + + // Enter data + sheet.WriteText(0, 0, 'Data'); + sheet.WriteFont(0, 0, '', 12, [fssBold], scBlack); + sheet.WriteText (2, 0, 'x'); sheet.Writetext (2, 1, 'y'); + sheet.WriteNumber(3, 0, 0.1); sheet.WriteFormula(3, 1, 'A4^2'); + sheet.WriteNumber(4, 0, 0.8); sheet.WriteFormula(4, 1, 'A5^2'); + sheet.WriteNumber(5, 0, 1.9); sheet.WriteFormula(5, 1, 'A6^2'); + sheet.WriteNumber(6, 0, 4.6); sheet.WriteFormula(6, 1, 'A7^2'); + sheet.WriteNumber(7, 0, 8.3); sheet.WriteFormula(7, 1, 'A8^2'); + sheet.WriteNumber(8, 0,15.9); sheet.WriteFormula(8, 1, 'A9^2'); + sheet.WriteNumber(9, 0,25.6); sheet.WriteFormula(9, 1, 'A10^2'); + sheet.WriteNumber(10,0,68.3); sheet.WriteFormula(10,1, 'A11^2'); + + // Create chart: left/top in cell D4, 150 mm x 100 mm + ch := book.AddChart(sheet, 2, 3, 150, 100); + + // Chart properties + ch.Border.Style := clsNoLine; + ch.Legend.Border.Style := clsNoLine; + ch.XAxis.Logarithmic := true; + ch.YAxis.Logarithmic := true; + + // Add scatter series + ser := TsScatterSeries.Create(ch); + + // Series properties + ser.SetTitleAddr(0, 0); + ser.SetXRange(3, 0, 10, 0); + ser.SetYRange(3, 1, 10, 1); + ser.ShowLines := true; + ser.ShowSymbols := true; + ser.Symbol := cssCircle; + + { + book.WriteToFile(FILE_NAME + '.xlsx', true); // Excel fails to open the file + WriteLn('Data saved with chart to ', FILE_NAME, '.xlsx'); + } + + book.Options := book.Options + [boCalcBeforeSaving]; + book.WriteToFile(FILE_NAME + '.ods', true); + WriteLn('Data saved with chart to ', FILE_NAME, '.ods'); + finally + book.Free; + end; +end. + diff --git a/components/fpspreadsheet/examples/other/chart/scatter_write_demo.lpi b/components/fpspreadsheet/examples/other/chart/scatter_write_demo.lpi new file mode 100644 index 000000000..5bab7e7e0 --- /dev/null +++ b/components/fpspreadsheet/examples/other/chart/scatter_write_demo.lpi @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="UTF-8"?> +<CONFIG> + <ProjectOptions> + <Version Value="12"/> + <PathDelim Value="\"/> + <General> + <Flags> + <MainUnitHasCreateFormStatements Value="False"/> + <MainUnitHasTitleStatement Value="False"/> + <MainUnitHasScaledStatement Value="False"/> + </Flags> + <SessionStorage Value="InProjectDir"/> + <Title Value="scatter_write_demo"/> + <UseAppBundle Value="False"/> + <ResourceType Value="res"/> + </General> + <BuildModes> + <Item Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + <UseFileFilters Value="True"/> + </PublishOptions> + <RunParams> + <FormatVersion Value="2"/> + </RunParams> + <RequiredPackages> + <Item> + <PackageName Value="laz_fpspreadsheet"/> + </Item> + </RequiredPackages> + <Units> + <Unit> + <Filename Value="scatter_write_demo.lpr"/> + <IsPartOfProject Value="True"/> + </Unit> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="scatter_write_demo"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <Debugging> + <DebugInfoType Value="dsDwarf3"/> + </Debugging> + </Linking> + <Other> + <ConfigFile> + <WriteConfigFilePath Value=""/> + </ConfigFile> + </Other> + </CompilerOptions> + <Debugging> + <Exceptions> + <Item> + <Name Value="EAbort"/> + </Item> + <Item> + <Name Value="ECodetoolError"/> + </Item> + <Item> + <Name Value="EFOpenError"/> + </Item> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/components/fpspreadsheet/examples/other/chart/scatter_write_demo.lpr b/components/fpspreadsheet/examples/other/chart/scatter_write_demo.lpr new file mode 100644 index 000000000..d3c0ebd64 --- /dev/null +++ b/components/fpspreadsheet/examples/other/chart/scatter_write_demo.lpr @@ -0,0 +1,65 @@ +program scatter_write_demo; + +{$mode objfpc}{$H+} + +uses + SysUtils, + fpspreadsheet, fpstypes, fpsUtils, fpschart, xlsxooxml, fpsopendocument; + +const + FILE_NAME = 'scatter'; +var + book: TsWorkbook; + sheet: TsWorksheet; + ch: TsChart; + ser: TsScatterSeries; +begin + book := TsWorkbook.Create; + try + // Worksheet + sheet := book.AddWorksheet('test'); + + // Enter data + sheet.WriteText (0, 0, 'Data'); + sheet.WriteFont (0, 0, '', 12, [fssBold], scBlack); + sheet.WriteText ( 2, 0, 'x'); sheet.WriteText ( 2, 1, 'y'); + sheet.WriteNumber( 3, 0, 0.1); sheet.WriteFormula( 3, 1, 'A4^2'); + sheet.WriteNumber( 4, 0, 8.8); sheet.WriteFormula( 4, 1, 'A5^2'); + sheet.WriteNumber( 5, 0,16.9); sheet.WriteFormula( 5, 1, 'A6^2'); + sheet.WriteNumber( 6, 0,24.6); sheet.WriteFormula( 6, 1, 'A7^2'); + sheet.WriteNumber( 7, 0,38.3); sheet.WriteFormula( 7, 1, 'A8^2'); + sheet.WriteNumber( 8, 0,45.9); sheet.WriteFormula( 8, 1, 'A9^2'); + sheet.WriteNumber( 9, 0,55.6); sheet.WriteFormula( 9, 1, 'A10^2'); + sheet.WriteNumber(10, 0,68.3); sheet.WriteFormula(10, 1, 'A11^2'); + + // Create chart: left/top in cell D4, 150 mm x 100 mm + ch := book.AddChart(sheet, 2, 3, 150, 100); + + // Chart properties + ch.Border.Style := clsNoLine; + ch.Legend.Border.Style := clsNoLine; + + // Add scatter series + ser := TsScatterSeries.Create(ch); + + // Series properties + ser.SetTitleAddr(0, 0); + ser.SetXRange(3, 0, 10, 0); + ser.SetYRange(3, 1, 10, 1); + ser.ShowLines := true; + ser.ShowSymbols := true; + ser.Symbol := cssCircle; + + { + book.WriteToFile(FILE_NAME + '.xlsx', true); // Excel fails to open the file + WriteLn('Data saved with chart to ', FILE_NAME, '.xlsx'); + } + + book.Options := book.Options + [boCalcBeforeSaving]; + book.WriteToFile(FILE_NAME + '.ods', true); + WriteLn('Data saved with chart to ', FILE_NAME, '.ods'); + finally + book.Free; + end; +end. + diff --git a/components/fpspreadsheet/examples/visual/fpschart/fpschartlink/main.lfm b/components/fpspreadsheet/examples/visual/fpschart/fpschartlink/main.lfm index 2e34f0f37..d8523edd3 100644 --- a/components/fpspreadsheet/examples/visual/fpschart/fpschartlink/main.lfm +++ b/components/fpspreadsheet/examples/visual/fpschart/fpschartlink/main.lfm @@ -99,6 +99,9 @@ object Form1: TForm1 '../../../other/chart/pie.ods' '../../../other/chart/radar.ods' '../../../other/chart/regression.ods' + '../../../other/chart/scatter.ods' + '../../../other/chart/scatter_log.ods' + '../../../other/chart/scatter_loglog.ods' ) TabOrder = 0 TextHint = 'Enter or select file name' diff --git a/components/fpspreadsheet/examples/visual/fpschart/fpschartlink/main.pas b/components/fpspreadsheet/examples/visual/fpschart/fpschartlink/main.pas index 3a1f0a07b..c6c8f3ca6 100644 --- a/components/fpspreadsheet/examples/visual/fpschart/fpschartlink/main.pas +++ b/components/fpspreadsheet/examples/visual/fpschart/fpschartlink/main.pas @@ -44,16 +44,6 @@ implementation {$R *.lfm} -const -// FILE_NAME = '../../../other/chart/bars.ods'; - FILE_NAME = '../../../other/chart/bubble.ods'; -// FILE_NAME = '../../../other/chart/area.ods'; -// FILE_NAME = '../../../other/chart/area-sameImg.ods'; -// FILE_NAME = '../../../other/chart/pie.ods'; -// FILE_NAME = '../../../other/chart/scatter.ods'; -// FILE_NAME = '../../../other/chart/regression.ods'; -// FILE_NAME = '../../../other/chart/radar.ods'; - { TForm1 } procedure TForm1.Button1Click(Sender: TObject);