You've already forked lazarus-ccr
fpspreadsheet: More work on ods writer of charts
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8978 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -16,10 +16,12 @@ begin
|
|||||||
// 1st sheet
|
// 1st sheet
|
||||||
sh1 := b.AddWorksheet('test1');
|
sh1 := b.AddWorksheet('test1');
|
||||||
sh1.WriteText(0, 1, 'sin(x)');
|
sh1.WriteText(0, 1, 'sin(x)');
|
||||||
|
sh1.WriteText(0, 2, 'sin(x/2)');
|
||||||
for i := 1 to 7 do
|
for i := 1 to 7 do
|
||||||
begin
|
begin
|
||||||
sh1.WriteNumber(i, 0, i-1);
|
sh1.WriteNumber(i, 0, i-1);
|
||||||
sh1.WriteNumber(i, 1, sin(i-1));
|
sh1.WriteNumber(i, 1, sin(i-1));
|
||||||
|
sh1.WriteNumber(i, 2, sin((i-1)/2));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ch := b.AddChart(sh1, 4, 4, 160, 100);
|
ch := b.AddChart(sh1, 4, 4, 160, 100);
|
||||||
@ -27,10 +29,18 @@ begin
|
|||||||
ser.SetTitleAddr(0, 1);
|
ser.SetTitleAddr(0, 1);
|
||||||
ser.SetLabelRange(1, 0, 7, 0);
|
ser.SetLabelRange(1, 0, 7, 0);
|
||||||
ser.SetYRange(1, 1, 7, 1);
|
ser.SetYRange(1, 1, 7, 1);
|
||||||
|
ser.Line.Color := scBlue;
|
||||||
|
TsLineSeries(ser).ShowSymbols := true;
|
||||||
|
TsLineSeries(ser).Symbol := cssCircle;
|
||||||
|
|
||||||
|
ser := TsLineSeries.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;
|
||||||
|
|
||||||
ch.Background.Style := fsSolidFill;
|
|
||||||
ch.Border.Style := clsSolid;
|
|
||||||
ch.PlotArea.Background.Style := fsSolidFill;
|
|
||||||
{$IFDEF DARK_MODE}
|
{$IFDEF DARK_MODE}
|
||||||
ch.Background.FgColor := scBlack;
|
ch.Background.FgColor := scBlack;
|
||||||
ch.Border.Color := scWhite;
|
ch.Border.Color := scWhite;
|
||||||
@ -40,23 +50,38 @@ begin
|
|||||||
ch.Border.Color := scBlack;
|
ch.Border.Color := scBlack;
|
||||||
ch.PlotArea.Background.FgColor := $F0F0F0;
|
ch.PlotArea.Background.FgColor := $F0F0F0;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
// Background and wall working
|
||||||
|
ch.Background.Style := fsSolidFill;
|
||||||
|
ch.Border.Style := clsSolid;
|
||||||
|
ch.PlotArea.Background.Style := fsSolidFill;
|
||||||
|
|
||||||
ch.XAxis.ShowLabels := true;
|
ch.XAxis.ShowLabels := true;
|
||||||
ch.XAxis.LabelFont.Size := 8;
|
ch.XAxis.LabelFont.Size := 8;
|
||||||
ch.XAxis.LabelFont.Color := scRed;
|
ch.XAxis.LabelFont.Color := scRed;
|
||||||
ch.XAxis.LabelFont.Style := [fssStrikeout];
|
ch.XAxis.LabelFont.Style := [fssStrikeout];
|
||||||
ch.XAxis.AxisLine.Color := scRed;
|
ch.XAxis.AxisLine.Color := scRed;
|
||||||
|
ch.XAxis.Caption := 'This is the x axis';
|
||||||
ch.XAxis.CaptionFont.Color := scRed;
|
ch.XAxis.CaptionFont.Color := scRed;
|
||||||
ch.XAxis.CaptionFont.Size := 12;
|
ch.XAxis.CaptionFont.Size := 12;
|
||||||
ch.XAxis.Inverted := true;
|
ch.XAxis.Inverted := true;
|
||||||
|
ch.XAxis.MajorGridLines.Color := scRed;
|
||||||
|
ch.XAxis.MinorGridLines.Color := scBlue;
|
||||||
|
ch.XAxis.MajorGridLines.Style := clsNoLine;//Solid;
|
||||||
|
ch.XAxis.MinorGridLines.Style := clsNoLine; //Solid;
|
||||||
|
|
||||||
ch.YAxis.ShowLabels := true;
|
ch.YAxis.ShowLabels := true;
|
||||||
ch.YAxis.LabelFont.Size := 8;
|
ch.YAxis.LabelFont.Size := 8;
|
||||||
ch.YAxis.LabelFont.Color := scBlue;
|
ch.YAxis.LabelFont.Color := scBlue;
|
||||||
ch.YAxis.AxisLine.Color := scBlue;
|
ch.YAxis.AxisLine.Color := scBlue;
|
||||||
|
ch.YAxis.Caption := 'This is the y axis';
|
||||||
ch.YAxis.CaptionFont.Color := scBlue;
|
ch.YAxis.CaptionFont.Color := scBlue;
|
||||||
ch.YAxis.CaptionFont.Size := 12;
|
ch.YAxis.CaptionFont.Size := 12;
|
||||||
ch.YAxis.LabelRotation := 90;
|
ch.YAxis.LabelRotation := 90;
|
||||||
ch.YAxis.CaptionRotation := 90;
|
ch.YAxis.CaptionRotation := 90;
|
||||||
|
ch.YAxis.MajorGridLines.Style := clsLongDash; //clsSolid;
|
||||||
|
ch.YAxis.MinorGridLines.Style := clsLongDashDot; //Dash; //clsSolid;
|
||||||
|
ch.YAxis.MajorGridLines.Color := scBlue;
|
||||||
|
ch.YAxis.MajorGridLines.Width := 1; // mm
|
||||||
|
|
||||||
ch.Title.Caption := 'HALLO';
|
ch.Title.Caption := 'HALLO';
|
||||||
ch.Title.Visible := true;
|
ch.Title.Visible := true;
|
||||||
@ -64,14 +89,13 @@ begin
|
|||||||
ch.SubTitle.Caption := 'hallo';
|
ch.SubTitle.Caption := 'hallo';
|
||||||
ch.SubTitle.Visible := true;
|
ch.SubTitle.Visible := true;
|
||||||
|
|
||||||
ch.YAxis.MajorGridLines.Style := clsSolid;
|
|
||||||
ch.YAxis.MinorGridLines.Style := clsSolid;
|
|
||||||
|
|
||||||
ch.Legend.Font.Size := 20;
|
// Legend working
|
||||||
ch.Legend.Font.Color := scGreen;
|
ch.Legend.Font.Size := 12;
|
||||||
ch.Legend.Border.Width := 3;
|
ch.Legend.Font.Color := scBlue;
|
||||||
ch.Legend.Border.Color := scRed;
|
ch.Legend.Border.Width := 0.3; // mm
|
||||||
ch.Legend.Background.FgColor := scYellow;
|
ch.Legend.Border.Color := scGray;
|
||||||
|
ch.Legend.Background.FgColor := scSilver;
|
||||||
ch.Legend.Background.Style := fsSolidFill;
|
ch.Legend.Background.Style := fsSolidFill;
|
||||||
|
|
||||||
// 2nd sheet
|
// 2nd sheet
|
||||||
@ -101,15 +125,22 @@ begin
|
|||||||
ch.Title.Visible := true;
|
ch.Title.Visible := true;
|
||||||
ch.SubTitle.Caption := 'hallo';
|
ch.SubTitle.Caption := 'hallo';
|
||||||
ch.Subtitle.Visible := true;
|
ch.Subtitle.Visible := true;
|
||||||
ch.XAxis.MajorGridLines.Style := clsNoLine;
|
ch.XAxis.MajorGridLines.Style := clsSolid; //NoLine;
|
||||||
ch.XAxis.MinorGridLines.Style := clsNoLine;
|
ch.XAxis.MinorGridLines.Style := clsNoLine;
|
||||||
ch.YAxis.MajorGridLines.Style := clsNoLine;
|
ch.YAxis.MajorGridLines.Style := clsNoLine;
|
||||||
ch.YAxis.MinorGridLines.Style := clsNoLine;
|
ch.YAxis.MinorGridLines.Style := clsNoLine;
|
||||||
|
ch.YAxis.CaptionRotation := 0;
|
||||||
|
ch.XAxis.CaptionFont.Size := 18;
|
||||||
|
ch.YAxis.CaptionFont.Size := 18;
|
||||||
|
ch.XAxis.LabelFont.Style := [fssItalic];
|
||||||
|
ch.YAxis.LabelFont.Style := [fssItalic];
|
||||||
|
|
||||||
b.WriteToFile('test.xlsx', true); // Excel fails to open the file
|
b.WriteToFile('test.xlsx', true); // Excel fails to open the file
|
||||||
b.WriteToFile('test.ods', true);
|
b.WriteToFile('test.ods', true);
|
||||||
finally
|
finally
|
||||||
b.Free;
|
b.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
ReadLn;
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -28,6 +28,10 @@ const
|
|||||||
DEFAULT_CHART_LINEWIDTH = 0.75; // pts
|
DEFAULT_CHART_LINEWIDTH = 0.75; // pts
|
||||||
DEFAULT_CHART_FONT = 'Arial';
|
DEFAULT_CHART_FONT = 'Arial';
|
||||||
|
|
||||||
|
DEFAULT_SERIES_COLORS: array[0..7] of TsColor = (
|
||||||
|
scRed, scBlue, scGreen, scMagenta, scPurple, scTeal, scBlack, scGray
|
||||||
|
);
|
||||||
|
|
||||||
type
|
type
|
||||||
TsChart = class;
|
TsChart = class;
|
||||||
|
|
||||||
@ -184,8 +188,12 @@ type
|
|||||||
FYAxis: TsChartAxisLink;
|
FYAxis: TsChartAxisLink;
|
||||||
FTitleAddr: TsCellCoord;
|
FTitleAddr: TsCellCoord;
|
||||||
FLabelFormat: String;
|
FLabelFormat: String;
|
||||||
|
FLine: TsChartLine;
|
||||||
|
FFill: TsChartFill;
|
||||||
|
FBorder: TsChartLine;
|
||||||
public
|
public
|
||||||
constructor Create(AChart: TsChart);
|
constructor Create(AChart: TsChart);
|
||||||
|
destructor Destroy; override;
|
||||||
function GetCount: Integer;
|
function GetCount: Integer;
|
||||||
function GetXCount: Integer;
|
function GetXCount: Integer;
|
||||||
function GetYCount: Integer;
|
function GetYCount: Integer;
|
||||||
@ -207,6 +215,10 @@ type
|
|||||||
property XRange: TsCellRange read FXRange;
|
property XRange: TsCellRange read FXRange;
|
||||||
property YRange: TsCellRange read FYRange;
|
property YRange: TsCellRange read FYRange;
|
||||||
property YAxis: TsChartAxisLink read FYAxis write FYAxis;
|
property YAxis: TsChartAxisLink read FYAxis write FYAxis;
|
||||||
|
|
||||||
|
property Border: TsChartLine read FBorder write FBorder;
|
||||||
|
property Fill: TsChartFill read FFill write FFill;
|
||||||
|
property Line: TsChartLine read FLine write FLine;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TsChartSeriesSymbol = (
|
TsChartSeriesSymbol = (
|
||||||
@ -216,21 +228,22 @@ type
|
|||||||
|
|
||||||
TsLineSeries = class(TsChartSeries)
|
TsLineSeries = class(TsChartSeries)
|
||||||
private
|
private
|
||||||
FLine: TsChartLine;
|
|
||||||
FSymbol: TsChartSeriesSymbol;
|
FSymbol: TsChartSeriesSymbol;
|
||||||
FSymbolFill: TsChartFill;
|
|
||||||
FSymbolBorder: TsChartLine;
|
|
||||||
FSymbolHeight: Double; // in mm
|
FSymbolHeight: Double; // in mm
|
||||||
FSymbolWidth: Double; // in mm
|
FSymbolWidth: Double; // in mm
|
||||||
|
FShowSymbols: Boolean;
|
||||||
|
function GetSymbolBorder: TsChartLine;
|
||||||
|
function GetSymbolFill: TsChartFill;
|
||||||
|
procedure SetSymbolBorder(Value: TsChartLine);
|
||||||
|
procedure SetSymbolFill(Value: TsChartFill);
|
||||||
public
|
public
|
||||||
constructor Create(AChart: TsChart);
|
constructor Create(AChart: TsChart);
|
||||||
destructor Destroy; override;
|
|
||||||
property Line: TsChartLine read FLine write FLine;
|
|
||||||
property Symbol: TsChartSeriesSymbol read FSymbol write FSymbol;
|
property Symbol: TsChartSeriesSymbol read FSymbol write FSymbol;
|
||||||
property SymbolBorder: TsChartLine read FSymbolBorder write FSymbolBorder;
|
property SymbolBorder: TsChartLine read GetSymbolBorder write SetSymbolBorder;
|
||||||
property SymbolFill: TsChartFill read FSymbolFill write FSymbolFill;
|
property SymbolFill: TsChartFill read GetSymbolFill write SetSymbolFill;
|
||||||
property SymbolHeight: double read FSymbolHeight write FSymbolHeight;
|
property SymbolHeight: double read FSymbolHeight write FSymbolHeight;
|
||||||
property SymbolWidth: double read FSymbolWidth write FSymbolWidth;
|
property SymbolWidth: double read FSymbolWidth write FSymbolWidth;
|
||||||
|
property ShowSymbols: Boolean read FShowSymbols write FShowSymbols;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TsChartSeriesList = class(TFPList)
|
TsChartSeriesList = class(TFPList)
|
||||||
@ -482,7 +495,7 @@ begin
|
|||||||
|
|
||||||
FMinorGridLines := TsChartLine.Create;
|
FMinorGridLines := TsChartLine.Create;
|
||||||
FMinorGridLines.Color := scSilver;
|
FMinorGridLines.Color := scSilver;
|
||||||
FMinorGridLines.Style := clsDot;
|
FMinorGridLines.Style := clsDash;
|
||||||
FMinorGridLines.Width := PtsToMM(DEFAULT_CHART_LINEWIDTH);
|
FMinorGridLines.Width := PtsToMM(DEFAULT_CHART_LINEWIDTH);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -519,9 +532,35 @@ end;
|
|||||||
{ TsChartSeries }
|
{ TsChartSeries }
|
||||||
|
|
||||||
constructor TsChartSeries.Create(AChart: TsChart);
|
constructor TsChartSeries.Create(AChart: TsChart);
|
||||||
|
var
|
||||||
|
idx: Integer;
|
||||||
begin
|
begin
|
||||||
inherited Create(AChart);
|
inherited Create(AChart);
|
||||||
AChart.AddSeries(self);
|
|
||||||
|
idx := AChart.AddSeries(self);
|
||||||
|
|
||||||
|
FBorder := TsChartLine.Create;
|
||||||
|
FBorder.Style := clsSolid;
|
||||||
|
FBorder.Width := PtsToMM(DEFAULT_CHART_LINEWIDTH);
|
||||||
|
FBorder.Color := scBlack;
|
||||||
|
|
||||||
|
FFill := TsChartFill.Create;
|
||||||
|
FFill.Style := fsSolidFill;
|
||||||
|
FFill.FgColor := DEFAULT_SERIES_COLORS[idx mod Length(DEFAULT_SERIES_COLORS)];
|
||||||
|
FFill.BgColor := DEFAULT_SERIES_COLORS[idx mod Length(DEFAULT_SERIES_COLORS)];
|
||||||
|
|
||||||
|
FLine := TsChartLine.Create;
|
||||||
|
FLine.Style := clsSolid;
|
||||||
|
FLine.Width := PtsToMM(DEFAULT_CHART_LINEWIDTH);
|
||||||
|
FLine.Color := DEFAULT_SERIES_COLORS[idx mod Length(DEFAULT_SERIES_COLORS)];
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TsChartSeries.Destroy;
|
||||||
|
begin
|
||||||
|
FLine.Free;
|
||||||
|
FFill.Free;
|
||||||
|
FBorder.Free;
|
||||||
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TsChartSeries.GetCount: Integer;
|
function TsChartSeries.GetCount: Integer;
|
||||||
@ -633,34 +672,29 @@ end;
|
|||||||
constructor TsLineSeries.Create(AChart: TsChart);
|
constructor TsLineSeries.Create(AChart: TsChart);
|
||||||
begin
|
begin
|
||||||
inherited Create(AChart);
|
inherited Create(AChart);
|
||||||
|
|
||||||
FChartType := ctLine;
|
FChartType := ctLine;
|
||||||
|
|
||||||
FLine := TsChartLine.Create;
|
|
||||||
FLine.Color := scBlack;
|
|
||||||
FLine.Style := clsSolid;
|
|
||||||
FLine.Width := PtsToMM(DEFAULT_CHART_LINEWIDTH);
|
|
||||||
|
|
||||||
FSymbolBorder := TsChartline.Create;
|
|
||||||
FSymbolBorder.Color := scBlack;
|
|
||||||
FSymbolBorder.Style := clsSolid;
|
|
||||||
FSymbolBorder.Width := PtsToMM(DEFAULT_CHART_LINEWIDTH);
|
|
||||||
|
|
||||||
FSymbolFill := TsChartFill.Create;
|
|
||||||
FSymbolFill.FgColor := scWhite;
|
|
||||||
FSymbolFill.BgColor := scWhite;
|
|
||||||
FSymbolFill.Style := fsSolidFill;
|
|
||||||
|
|
||||||
FSymbolWidth := 2.5;
|
FSymbolWidth := 2.5;
|
||||||
FSymbolHeight := 2.5;
|
FSymbolHeight := 2.5;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TsLineSeries.Destroy;
|
function TsLineSeries.GetSymbolBorder: TsChartLine;
|
||||||
begin
|
begin
|
||||||
FSymbolFill.Free;
|
Result := FBorder;
|
||||||
FSymbolBorder.Free;
|
end;
|
||||||
FLine.Free;
|
|
||||||
inherited;
|
function TsLineSeries.GetSymbolFill: TsChartFill;
|
||||||
|
begin
|
||||||
|
Result := FFill;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TsLineSeries.SetSymbolBorder(Value: TsChartLine);
|
||||||
|
begin
|
||||||
|
FBorder := Value;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TsLineSeries.SetSymbolFill(Value: TsChartFill);
|
||||||
|
begin
|
||||||
|
FFill := Value;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user