diff --git a/components/fpspreadsheet/examples/other/chart/write_chart_demo.lpr b/components/fpspreadsheet/examples/other/chart/write_chart_demo.lpr
index a917d2e58..00b4a107f 100644
--- a/components/fpspreadsheet/examples/other/chart/write_chart_demo.lpr
+++ b/components/fpspreadsheet/examples/other/chart/write_chart_demo.lpr
@@ -100,6 +100,7 @@ begin
ch.Legend.Border.Color := scGray;
ch.Legend.Background.FgColor := scSilver;
ch.Legend.Background.Style := fsSolidFill;
+ ch.Legend.CanOverlapPlotArea := true;
// 2nd sheet
sh2 := b.AddWorksheet('test2');
diff --git a/components/fpspreadsheet/source/common/fpschart.pas b/components/fpspreadsheet/source/common/fpschart.pas
index 7dfbca3ad..1872fac5e 100644
--- a/components/fpspreadsheet/source/common/fpschart.pas
+++ b/components/fpspreadsheet/source/common/fpschart.pas
@@ -171,9 +171,11 @@ type
TsChartLegend = class(TsChartFillElement)
private
FFont: TsFont;
+ FCanOverlapPlotArea: Boolean;
public
constructor Create(AChart: TsChart);
destructor Destroy; override;
+ property CanOverlapPlotArea: Boolean read FCanOverlapPlotArea write FCanOverlapPlotArea;
property Font: TsFont read FFont write FFont;
end;
diff --git a/components/fpspreadsheet/source/common/fpschartstyles.pas b/components/fpspreadsheet/source/common/fpschartstyles.pas
index 876c05e5e..866e565c8 100644
--- a/components/fpspreadsheet/source/common/fpschartstyles.pas
+++ b/components/fpspreadsheet/source/common/fpschartstyles.pas
@@ -93,6 +93,7 @@ type
end;
TsChartLegendRec = record
+ CanOverlapPlotArea: Boolean;
Font: TsChartFontRec;
Border: TsChartLineRec;
Fill: TsChartFillRec;
@@ -599,6 +600,7 @@ end;
{ TsChartLegendRec }
procedure TsChartLegendRec.FromChart(AChart: TsChart; AElement: TsChartStyleElement);
begin
+ CanOverlapPlotArea := AChart.Legend.CanOverlapPlotArea;
Font.FromChart(AChart, ceLegend);
Border.FromChart(AChart, ceLegend, 0);
Fill.FromChart(AChart, ceLegend, 0);
@@ -607,6 +609,7 @@ end;
procedure TsChartLegendRec.ToChart(AChart: TsChart; AElement: TsChartStyleElement);
begin
+ AChart.Legend.CanOverlapPlotArea := CanOverlapPlotArea;
Font.ToChart(AChart, ceLegend);
Border.ToChart(AChart, ceLegend, 0);
Fill.ToChart(AChart, ceLegend, 0);
@@ -616,7 +619,7 @@ end;
class operator TsChartLegendRec.= (A, B: TsChartLegendRec): Boolean;
begin
Result := (A.Font = B.Font) and (A.Border = B.Border) and (A.Fill = B.Fill) and
- (A.Visible = B.Visible);
+ (A.Visible = B.Visible) and (A.CanOverlapPlotArea = B.CanOverlapPlotArea);
end;
{ TsChartPlotAreaRec }
diff --git a/components/fpspreadsheet/source/common/fpsopendocument.pas b/components/fpspreadsheet/source/common/fpsopendocument.pas
index 552588738..de7734224 100644
--- a/components/fpspreadsheet/source/common/fpsopendocument.pas
+++ b/components/fpspreadsheet/source/common/fpsopendocument.pas
@@ -7005,18 +7005,23 @@ procedure TsSpreadOpenDocWriter.WriteChartLegend(AStream: TStream; AChart: TsCha
var
ind: String;
styles: TsChartStyleList;
+ style: TsChartStyle_Legend;
idx: Integer = 400;
+ canOverlap: String = '';
begin
if (not AChart.Legend.Visible) then
exit;
styles := TsChartStyleList(FChartStyleList);
idx := styles.AddChartStyle('Legend', AChart, TsChartstyle_Legend, ceLegend);
+ style := TsChartStyle_Legend(styles[idx]);
+ if style.Legend.CanOverlapPlotArea then
+ canOverlap := 'loext:overlay="true" ';
ind := DupeString(' ', AIndent);
AppendToStream(AStream, Format(
- ind + '' + LE,
- [ idx + 1 ]
+ ind + '' + LE,
+ [ idx + 1, canOverlap ]
));
{$ifdef DEBUG_CHART_STYLES}