You've already forked lazarus-ccr
fpspreadsheet: Support chart legend position in ods writer.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8984 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -98,9 +98,10 @@ begin
|
||||
ch.Legend.Font.Color := scBlue;
|
||||
ch.Legend.Border.Width := 0.3; // mm
|
||||
ch.Legend.Border.Color := scGray;
|
||||
ch.Legend.Background.FgColor := scSilver;
|
||||
ch.Legend.Background.FgColor := $F0F0F0;
|
||||
ch.Legend.Background.Style := fsSolidFill;
|
||||
ch.Legend.CanOverlapPlotArea := true;
|
||||
//ch.Legend.CanOverlapPlotArea := true;
|
||||
ch.Legend.Position := lpBottom;
|
||||
|
||||
// 2nd sheet
|
||||
sh2 := b.AddWorksheet('test2');
|
||||
|
@ -168,15 +168,19 @@ type
|
||||
property ShowLabels: Boolean read FShowLabels write FShowLabels;
|
||||
end;
|
||||
|
||||
TsChartLegendPosition = (lpRight, lpTop, lpBottom, lpLeft);
|
||||
|
||||
TsChartLegend = class(TsChartFillElement)
|
||||
private
|
||||
FFont: TsFont;
|
||||
FCanOverlapPlotArea: Boolean;
|
||||
FPosition: TsChartLegendPosition;
|
||||
public
|
||||
constructor Create(AChart: TsChart);
|
||||
destructor Destroy; override;
|
||||
property CanOverlapPlotArea: Boolean read FCanOverlapPlotArea write FCanOverlapPlotArea;
|
||||
property Font: TsFont read FFont write FFont;
|
||||
property Position: TsChartLegendPosition read FPosition write FPosition;
|
||||
end;
|
||||
|
||||
TsChartAxisLink = (alPrimary, alSecondary);
|
||||
|
@ -97,6 +97,7 @@ type
|
||||
Font: TsChartFontRec;
|
||||
Border: TsChartLineRec;
|
||||
Fill: TsChartFillRec;
|
||||
Position: TsChartLegendPosition;
|
||||
Visible: Boolean;
|
||||
procedure FromChart(AChart: TsChart; AElement: TsChartStyleElement);
|
||||
procedure ToChart(AChart: TsChart; AElement: TsChartStyleElement);
|
||||
@ -605,6 +606,7 @@ begin
|
||||
Border.FromChart(AChart, ceLegend, 0);
|
||||
Fill.FromChart(AChart, ceLegend, 0);
|
||||
Visible := AChart.Legend.Visible;
|
||||
Position := AChart.Legend.Position;
|
||||
end;
|
||||
|
||||
procedure TsChartLegendRec.ToChart(AChart: TsChart; AElement: TsChartStyleElement);
|
||||
@ -614,12 +616,14 @@ begin
|
||||
Border.ToChart(AChart, ceLegend, 0);
|
||||
Fill.ToChart(AChart, ceLegend, 0);
|
||||
AChart.Legend.Visible := Visible;
|
||||
AChart.Legend.Position := Position;
|
||||
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) and (A.CanOverlapPlotArea = B.CanOverlapPlotArea);
|
||||
(A.Visible = B.Visible) and (A.CanOverlapPlotArea = B.CanOverlapPlotArea) and
|
||||
(A.Position = B.Position);
|
||||
end;
|
||||
|
||||
{ TsChartPlotAreaRec }
|
||||
|
@ -7002,6 +7002,10 @@ end;
|
||||
{ Writes the chart's legend to the xml stream }
|
||||
procedure TsSpreadOpenDocWriter.WriteChartLegend(AStream: TStream; AChart: TsChart;
|
||||
AIndent: Integer);
|
||||
const
|
||||
LEGEND_POSITION: array[TsChartLegendPosition] of string = (
|
||||
'end', 'top', 'bottom', 'start'
|
||||
);
|
||||
var
|
||||
ind: String;
|
||||
styles: TsChartStyleList;
|
||||
@ -7020,8 +7024,8 @@ begin
|
||||
canOverlap := 'loext:overlay="true" ';
|
||||
ind := DupeString(' ', AIndent);
|
||||
AppendToStream(AStream, Format(
|
||||
ind + '<chart:legend chart:style-name="ch%d" chart:legend-position="end" style:legend-expansion="high" %s/>' + LE,
|
||||
[ idx + 1, canOverlap ]
|
||||
ind + '<chart:legend chart:style-name="ch%d" chart:legend-position="%s" style:legend-expansion="high" %s/>' + LE,
|
||||
[ idx + 1, LEGEND_POSITION[style.Legend.Position], canOverlap ]
|
||||
));
|
||||
|
||||
{$ifdef DEBUG_CHART_STYLES}
|
||||
|
Reference in New Issue
Block a user