fpspreadsheet: Chart link supports stacked area and line series.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9049 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-11-27 21:37:13 +00:00
parent 114d89432d
commit bdd483000f
2 changed files with 21 additions and 12 deletions

View File

@@ -35,8 +35,8 @@ implementation
{$R *.lfm} {$R *.lfm}
const const
FILE_NAME = '../../../other/chart/bars.ods'; // FILE_NAME = '../../../other/chart/bars.ods';
// FILE_NAME = '../../../other/chart/area.ods'; FILE_NAME = '../../../other/chart/area.ods';
// FILE_NAME = '../../../other/chart/area-sameImg.ods'; // FILE_NAME = '../../../other/chart/area-sameImg.ods';
// FILE_NAME = '../../../other/chart/pie.ods'; // FILE_NAME = '../../../other/chart/pie.ods';
// FILE_NAME = '../../../other/chart/scatter.ods'; // FILE_NAME = '../../../other/chart/scatter.ods';

View File

@@ -130,7 +130,7 @@ type
procedure UpdateChartAxis(AWorkbookAxis: TsChartAxis); procedure UpdateChartAxis(AWorkbookAxis: TsChartAxis);
procedure UpdateChartAxisLabels(AWorkbookChart: TsChart); procedure UpdateChartAxisLabels(AWorkbookChart: TsChart);
procedure UpdateChartBackground(AWorkbookChart: TsChart); procedure UpdateChartBackground(AWorkbookChart: TsChart);
procedure UpdateBarSeries(AWorkbookChart: TsChart); // procedure UpdateBarSeries(AWorkbookChart: TsChart);
procedure UpdateChartBrush(AWorkbookChart: TsChart; AWorkbookFill: TsChartFill; ABrush: TBrush); procedure UpdateChartBrush(AWorkbookChart: TsChart; AWorkbookFill: TsChartFill; ABrush: TBrush);
procedure UpdateChartLegend(AWorkbookLegend: TsChartLegend; ALegend: TChartLegend); procedure UpdateChartLegend(AWorkbookLegend: TsChartLegend; ALegend: TChartLegend);
procedure UpdateChartPen(AWorkbookChart: TsChart; AWorkbookLine: TsChartLine; APen: TPen); procedure UpdateChartPen(AWorkbookChart: TsChart; AWorkbookLine: TsChartLine; APen: TPen);
@@ -912,7 +912,8 @@ begin
TAreaSeries(Result).Styles := FChartStyles; TAreaSeries(Result).Styles := FChartStyles;
Result.Legend.Multiplicity := lmStyle; Result.Legend.Multiplicity := lmStyle;
src.SetTitleAddr(ASeries.TitleAddr); src.SetTitleAddr(ASeries.TitleAddr);
end else end
else
begin begin
case ASeries.ChartType of case ASeries.ChartType of
ctBar: ctBar:
@@ -952,7 +953,10 @@ begin
ser.Transparency := round(ASeries.Fill.Transparency); ser.Transparency := round(ASeries.Fill.Transparency);
UpdateChartSeriesMarks(ASeries, ser); UpdateChartSeriesMarks(ASeries, ser);
if IsStackable(ASeries) then if IsStackable(ASeries) then
begin
UpdateChartStyle(ASeries, ser, FChartStyles.Styles.Count-1); UpdateChartStyle(ASeries, ser, FChartStyles.Styles.Count-1);
FChart.Legend.Inverted := ASeries.Chart.StackMode <> csmSideBySide;
end;
FChart.AddSeries(ser); FChart.AddSeries(ser);
@@ -1283,6 +1287,11 @@ begin
UpdateChartBrush(AWorkbookSeries.Chart, AWorkbookSeries.Fill, AChartSeries.AreaBrush); UpdateChartBrush(AWorkbookSeries.Chart, AWorkbookSeries.Fill, AChartSeries.AreaBrush);
UpdateChartPen(AWorkbookSeries.Chart, AWorkbookSeries.Line, AChartSeries.AreaContourPen); UpdateChartPen(AWorkbookSeries.Chart, AWorkbookSeries.Line, AChartSeries.AreaContourPen);
AChartSeries.AreaLinesPen.Style := psClear; AChartSeries.AreaLinesPen.Style := psClear;
case AWorkbookSeries.Chart.StackMode of
csmSideBySide: AChartSeries.Stacked := false;
csmStacked: AChartSeries.Stacked := true;
csmStackedPercentage: AChartSeries.Stacked := true;
end;
end; end;
procedure TsWorkbookChartLink.UpdateBarSeries(AWorkbookSeries: TsBarSeries; procedure TsWorkbookChartLink.UpdateBarSeries(AWorkbookSeries: TsBarSeries;
@@ -1295,7 +1304,6 @@ begin
csmStacked: AChartSeries.Stacked := true; csmStacked: AChartSeries.Stacked := true;
csmStackedPercentage: AChartSeries.Stacked := true; csmStackedPercentage: AChartSeries.Stacked := true;
end; end;
AChartSeries.ParentChart.Legend.Inverted := AChartSeries.Stacked;
end; end;
procedure TsWorkbookChartLink.UpdateChart; procedure TsWorkbookChartLink.UpdateChart;
@@ -1326,7 +1334,7 @@ begin
FChart.Prepare; FChart.Prepare;
UpdateChartAxisLabels(ch); UpdateChartAxisLabels(ch);
UpdateBarSeries(ch); // UpdateBarSeries(ch);
FixAreaSeries(ch); FixAreaSeries(ch);
end; end;
@@ -1430,18 +1438,13 @@ begin
FChart.Frame.Visible := AWorkbookChart.PlotArea.Border.Style <> clsNoLine; FChart.Frame.Visible := AWorkbookChart.PlotArea.Border.Style <> clsNoLine;
end; end;
{
procedure TsWorkbookChartLink.UpdateBarSeries(AWorkbookChart: TsChart); procedure TsWorkbookChartLink.UpdateBarSeries(AWorkbookChart: TsChart);
var var
i, n: Integer; i, n: Integer;
ser: TBarSeries; ser: TBarSeries;
barWidth, totalBarWidth: Integer; barWidth, totalBarWidth: Integer;
begin begin
exit;
if AWorkbookChart.GetChartType <> ctBar then if AWorkbookChart.GetChartType <> ctBar then
exit; exit;
@@ -1476,6 +1479,7 @@ begin
end; end;
end; end;
end; end;
}
procedure TsWorkbookChartLink.UpdateChartBrush(AWorkbookChart: TsChart; procedure TsWorkbookChartLink.UpdateChartBrush(AWorkbookChart: TsChart;
AWorkbookFill: TsChartFill; ABrush: TBrush); AWorkbookFill: TsChartFill; ABrush: TBrush);
@@ -1668,6 +1672,11 @@ begin
AChartSeries.Pointer.HorizSize := mmToPx(AWorkbookSeries.SymbolWidth, ppi); AChartSeries.Pointer.HorizSize := mmToPx(AWorkbookSeries.SymbolWidth, ppi);
AChartSeries.Pointer.VertSize := mmToPx(AWorkbookSeries.SymbolHeight, ppi); AChartSeries.Pointer.VertSize := mmToPx(AWorkbookSeries.SymbolHeight, ppi);
end; end;
case AWorkbookSeries.Chart.StackMode of
csmSideBySide: AChartSeries.Stacked := false;
csmStacked: AChartSeries.Stacked := true;
csmStackedPercentage: AChartSeries.Stacked := true;
end;
end; end;
procedure TsWorkbookChartLink.UpdatePieSeries(AWorkbookSeries: TsPieSeries; procedure TsWorkbookChartLink.UpdatePieSeries(AWorkbookSeries: TsPieSeries;