You've already forked lazarus-ccr
fpspreadsheet: Simplify creation of the chart styles by the ods writer.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8986 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -4,6 +4,8 @@ program write_chart_demo;
|
||||
|
||||
uses
|
||||
SysUtils, fpspreadsheet, fpstypes, fpschart, xlsxooxml, fpsopendocument;
|
||||
const
|
||||
SERIES_CLASS: TsChartSeriesClass = TsBarSeries;
|
||||
var
|
||||
b: TsWorkbook;
|
||||
sh1, sh2, sh3: TsWorksheet;
|
||||
@ -15,41 +17,42 @@ begin
|
||||
try
|
||||
// 1st sheet
|
||||
sh1 := b.AddWorksheet('test1');
|
||||
sh1.WriteText(0, 1, 'sin(x)');
|
||||
sh1.WriteText(0, 2, 'sin(x/2)');
|
||||
sh1.WriteText(0, 1, '1+sin(x)');
|
||||
sh1.WriteText(0, 2, '1+sin(x/2)');
|
||||
for i := 1 to 7 do
|
||||
begin
|
||||
sh1.WriteNumber(i, 0, i-1);
|
||||
sh1.WriteNumber(i, 1, sin(i-1));
|
||||
sh1.WriteNumber(i, 2, sin((i-1)/2));
|
||||
sh1.WriteNumber(i, 1, 1+sin(i-1));
|
||||
sh1.WriteNumber(i, 2, 1+sin((i-1)/2));
|
||||
end;
|
||||
|
||||
// Create chart
|
||||
ch := b.AddChart(sh1, 4, 4, 160, 100);
|
||||
{
|
||||
ser := TsLineSeries.Create(ch);
|
||||
|
||||
// Add first series (type depending on SERIES_CLASS)
|
||||
ser := SERIES_CLASS.Create(ch);
|
||||
ser.SetTitleAddr(0, 1);
|
||||
ser.SetLabelRange(1, 0, 7, 0);
|
||||
ser.SetYRange(1, 1, 7, 1);
|
||||
ser.Line.Color := scBlue;
|
||||
TsLineSeries(ser).ShowSymbols := true;
|
||||
TsLineSeries(ser).Symbol := cssCircle;
|
||||
}
|
||||
ser := TsBarSeries.Create(ch);
|
||||
ser.SetTitleAddr(0, 2);
|
||||
ser.SetLabelRange(1, 0, 7, 0);
|
||||
ser.SetYRange(1, 2, 7, 2);
|
||||
ser.Fill.FgColor := scRed;
|
||||
TsBarSeries(ser).Kind := bskBars;
|
||||
ser.Fill.FgColor := scBlue;
|
||||
if (ser is TsLineSeries) then
|
||||
begin
|
||||
TsLineSeries(ser).ShowSymbols := true;
|
||||
TsLineSeries(ser).Symbol := cssCircle;
|
||||
end;
|
||||
if (ser is TsBarSeries) then
|
||||
begin
|
||||
TsBarSeries(ser).Kind := bskBars;
|
||||
end;
|
||||
|
||||
{
|
||||
ser := TsLineSeries.Create(ch);
|
||||
// Add second series
|
||||
ser := SERIES_CLASS.Create(ch);
|
||||
ser.SetTitleAddr(0, 2);
|
||||
ser.SetLabelRange(1, 0, 7, 0);
|
||||
ser.SetYRange(1, 2, 7, 2);
|
||||
ser.Line.Color := scRed;
|
||||
TsLineSeries(ser).ShowSymbols := true;
|
||||
TsLineSeries(ser).Symbol := cssDiamond;
|
||||
}
|
||||
ser.Fill.FgColor := scRed;
|
||||
|
||||
{$IFDEF DARK_MODE}
|
||||
ch.Background.FgColor := scBlack;
|
||||
@ -102,7 +105,6 @@ begin
|
||||
ch.SubTitle.Caption := 'hallo';
|
||||
ch.SubTitle.Visible := true;
|
||||
|
||||
|
||||
// Legend working
|
||||
ch.Legend.Font.Size := 12;
|
||||
ch.Legend.Font.Color := scBlue;
|
||||
@ -159,6 +161,6 @@ begin
|
||||
|
||||
WriteLn;
|
||||
Write('Press ENTER to close...');
|
||||
ReadLn;
|
||||
// ReadLn;
|
||||
end.
|
||||
|
||||
|
@ -98,6 +98,7 @@ type
|
||||
TsChartText = class(TsChartFillElement)
|
||||
private
|
||||
FCaption: String;
|
||||
FRotationAngle: Integer;
|
||||
FShowCaption: Boolean;
|
||||
FFont: TsFont;
|
||||
public
|
||||
@ -106,6 +107,7 @@ type
|
||||
property Caption: String read FCaption write FCaption;
|
||||
property Font: TsFont read FFont write FFont;
|
||||
property ShowCaption: Boolean read FShowCaption write FShowCaption;
|
||||
property RotationAngle: Integer read FRotationAngle write FRotationAngle;
|
||||
end;
|
||||
|
||||
TsChartAxisPosition = (capStart, capEnd, capValue);
|
||||
@ -198,7 +200,7 @@ type
|
||||
FFill: TsChartFill;
|
||||
FBorder: TsChartLine;
|
||||
public
|
||||
constructor Create(AChart: TsChart);
|
||||
constructor Create(AChart: TsChart); virtual;
|
||||
destructor Destroy; override;
|
||||
function GetCount: Integer;
|
||||
function GetXCount: Integer;
|
||||
@ -226,6 +228,7 @@ type
|
||||
property Fill: TsChartFill read FFill write FFill;
|
||||
property Line: TsChartLine read FLine write FLine;
|
||||
end;
|
||||
TsChartSeriesClass = class of TsChartSeries;
|
||||
|
||||
TsBarSeriesKind = (bskColumns, bskBars);
|
||||
|
||||
@ -233,7 +236,7 @@ type
|
||||
private
|
||||
FKind: TsBarSeriesKind;
|
||||
public
|
||||
constructor Create(AChart: TsChart);
|
||||
constructor Create(AChart: TsChart); override;
|
||||
property Kind: TsBarSeriesKind read FKind write FKind;
|
||||
end;
|
||||
|
||||
@ -253,7 +256,7 @@ type
|
||||
procedure SetSymbolBorder(Value: TsChartLine);
|
||||
procedure SetSymbolFill(Value: TsChartFill);
|
||||
public
|
||||
constructor Create(AChart: TsChart);
|
||||
constructor Create(AChart: TsChart); override;
|
||||
property Symbol: TsChartSeriesSymbol read FSymbol write FSymbol;
|
||||
property SymbolBorder: TsChartLine read GetSymbolBorder write SetSymbolBorder;
|
||||
property SymbolFill: TsChartFill read GetSymbolFill write SetSymbolFill;
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user