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