You've already forked lazarus-ccr
fpspreadsheet: ods chart writer supports legend overlapping with plot area.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8982 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -100,6 +100,7 @@ begin
|
|||||||
ch.Legend.Border.Color := scGray;
|
ch.Legend.Border.Color := scGray;
|
||||||
ch.Legend.Background.FgColor := scSilver;
|
ch.Legend.Background.FgColor := scSilver;
|
||||||
ch.Legend.Background.Style := fsSolidFill;
|
ch.Legend.Background.Style := fsSolidFill;
|
||||||
|
ch.Legend.CanOverlapPlotArea := true;
|
||||||
|
|
||||||
// 2nd sheet
|
// 2nd sheet
|
||||||
sh2 := b.AddWorksheet('test2');
|
sh2 := b.AddWorksheet('test2');
|
||||||
|
@@ -171,9 +171,11 @@ type
|
|||||||
TsChartLegend = class(TsChartFillElement)
|
TsChartLegend = class(TsChartFillElement)
|
||||||
private
|
private
|
||||||
FFont: TsFont;
|
FFont: TsFont;
|
||||||
|
FCanOverlapPlotArea: Boolean;
|
||||||
public
|
public
|
||||||
constructor Create(AChart: TsChart);
|
constructor Create(AChart: TsChart);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
property CanOverlapPlotArea: Boolean read FCanOverlapPlotArea write FCanOverlapPlotArea;
|
||||||
property Font: TsFont read FFont write FFont;
|
property Font: TsFont read FFont write FFont;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@@ -93,6 +93,7 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
TsChartLegendRec = record
|
TsChartLegendRec = record
|
||||||
|
CanOverlapPlotArea: Boolean;
|
||||||
Font: TsChartFontRec;
|
Font: TsChartFontRec;
|
||||||
Border: TsChartLineRec;
|
Border: TsChartLineRec;
|
||||||
Fill: TsChartFillRec;
|
Fill: TsChartFillRec;
|
||||||
@@ -599,6 +600,7 @@ end;
|
|||||||
{ TsChartLegendRec }
|
{ TsChartLegendRec }
|
||||||
procedure TsChartLegendRec.FromChart(AChart: TsChart; AElement: TsChartStyleElement);
|
procedure TsChartLegendRec.FromChart(AChart: TsChart; AElement: TsChartStyleElement);
|
||||||
begin
|
begin
|
||||||
|
CanOverlapPlotArea := AChart.Legend.CanOverlapPlotArea;
|
||||||
Font.FromChart(AChart, ceLegend);
|
Font.FromChart(AChart, ceLegend);
|
||||||
Border.FromChart(AChart, ceLegend, 0);
|
Border.FromChart(AChart, ceLegend, 0);
|
||||||
Fill.FromChart(AChart, ceLegend, 0);
|
Fill.FromChart(AChart, ceLegend, 0);
|
||||||
@@ -607,6 +609,7 @@ end;
|
|||||||
|
|
||||||
procedure TsChartLegendRec.ToChart(AChart: TsChart; AElement: TsChartStyleElement);
|
procedure TsChartLegendRec.ToChart(AChart: TsChart; AElement: TsChartStyleElement);
|
||||||
begin
|
begin
|
||||||
|
AChart.Legend.CanOverlapPlotArea := CanOverlapPlotArea;
|
||||||
Font.ToChart(AChart, ceLegend);
|
Font.ToChart(AChart, ceLegend);
|
||||||
Border.ToChart(AChart, ceLegend, 0);
|
Border.ToChart(AChart, ceLegend, 0);
|
||||||
Fill.ToChart(AChart, ceLegend, 0);
|
Fill.ToChart(AChart, ceLegend, 0);
|
||||||
@@ -616,7 +619,7 @@ end;
|
|||||||
class operator TsChartLegendRec.= (A, B: TsChartLegendRec): Boolean;
|
class operator TsChartLegendRec.= (A, B: TsChartLegendRec): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := (A.Font = B.Font) and (A.Border = B.Border) and (A.Fill = B.Fill) and
|
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;
|
end;
|
||||||
|
|
||||||
{ TsChartPlotAreaRec }
|
{ TsChartPlotAreaRec }
|
||||||
|
@@ -7005,18 +7005,23 @@ procedure TsSpreadOpenDocWriter.WriteChartLegend(AStream: TStream; AChart: TsCha
|
|||||||
var
|
var
|
||||||
ind: String;
|
ind: String;
|
||||||
styles: TsChartStyleList;
|
styles: TsChartStyleList;
|
||||||
|
style: TsChartStyle_Legend;
|
||||||
idx: Integer = 400;
|
idx: Integer = 400;
|
||||||
|
canOverlap: String = '';
|
||||||
begin
|
begin
|
||||||
if (not AChart.Legend.Visible) then
|
if (not AChart.Legend.Visible) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
styles := TsChartStyleList(FChartStyleList);
|
styles := TsChartStyleList(FChartStyleList);
|
||||||
idx := styles.AddChartStyle('Legend', AChart, TsChartstyle_Legend, ceLegend);
|
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);
|
ind := DupeString(' ', AIndent);
|
||||||
AppendToStream(AStream, Format(
|
AppendToStream(AStream, Format(
|
||||||
ind + '<chart:legend chart:style-name="ch%d" chart:legend-position="end" style:legend-expansion="high" />' + LE,
|
ind + '<chart:legend chart:style-name="ch%d" chart:legend-position="end" style:legend-expansion="high" %s/>' + LE,
|
||||||
[ idx + 1 ]
|
[ idx + 1, canOverlap ]
|
||||||
));
|
));
|
||||||
|
|
||||||
{$ifdef DEBUG_CHART_STYLES}
|
{$ifdef DEBUG_CHART_STYLES}
|
||||||
|
Reference in New Issue
Block a user