fpspreadsheet: xlsx writer supports area series.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9202 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2024-02-03 00:06:15 +00:00
parent 2f7b18bd8c
commit 9137a34697
3 changed files with 66 additions and 3 deletions

View File

@ -13,7 +13,7 @@ begin
WriteLn(' rotated ........... horizontal bars');
WriteLn(' side-by-side ...... bars side-by-side (default)');
WriteLn(' stacked ........... stacked bars');
WriteLn(' percentstacked .... stacked by percentage');
WriteLn(' percent-stacked ... stacked by percentage');
Halt;
end;
@ -29,6 +29,9 @@ var
rotated: Boolean = false;
i: Integer;
begin
if ParamCount = 0 then
WriteHelp;
fn := FILE_NAME;
for i := 1 to ParamCount do
@ -39,7 +42,7 @@ begin
stackMode := csmStacked;
'side-by-side':
stackMode := csmSideBySide;
'percent-stacked', 'stacked-percent':
'percent-stacked', 'stacked-percent', 'percentstacked', 'stackedpercent', 'percentage', 'percent':
stackMode := csmStackedPercentage;
end;

View File

@ -1,6 +1,14 @@
@echo off
echo Generating chart demo files:
echo.
echo Area series...
areachart_write_demo
areachart_write_demo stacked
areachart_write_demo percentage
areachart_write_demo rotated
areachart_write_demo stacked rotated
areachart_write_demo percentage rotated
echo.
echo Bar series...
barchart_write_demo
barchart_write_demo rotated

View File

@ -107,6 +107,7 @@ type
procedure WriteChartTitleNode(AStream: TStream; AIndent: Integer; ATitle: TsChartText);
// Writing the nodes of the series types
procedure WriteAreaSeries(AStream: TStream; AIndent: Integer; ASeries: TsAreaSeries; ASeriesIndex: Integer);
procedure WriteBarSeries(AStream: TStream; AIndent: Integer; ASeries: TsBarSeries; ASeriesIndex: Integer);
procedure WriteScatterSeries(AStream: TStream; AIndent: Integer; ASeries: TsScatterSeries; ASeriesIndex: Integer);
@ -159,7 +160,6 @@ const
AX_POS: array[TsChartAxisAlignment] of string = ('l', 't', 'r', 'b');
FALSE_TRUE: Array[boolean] of String = ('0', '1');
LEGEND_POS: Array[TsChartLegendPosition] of string = ('r', 't', 'b', 'l');
GROUPING: Array[TsChartStackMode] of string = ('clustered', 'stacked', 'percentStacked');
{$INCLUDE xlsxooxmlchart_hatch.inc}
@ -3356,12 +3356,62 @@ begin
);
end;
{@@ ----------------------------------------------------------------------------
Writes the properties of the given area series to the <c:plotArea> node of
file chartN.xml
-------------------------------------------------------------------------------}
procedure TsSpreadOOXMLChartWriter.WriteAreaSeries(AStream: TStream;
AIndent: Integer; ASeries: TsAreaSeries; ASeriesIndex: Integer);
const
GROUPING: Array[TsChartStackMode] of string = ('standard', 'stacked', 'percentStacked');
var
indent: String;
chart: TsChart;
isFirstOfGroup: Boolean = true;
isLastOfGroup: Boolean = true;
begin
indent := DupeString(' ', AIndent);
chart := ASeries.Chart;
if ASeries.GroupIndex > -1 then
begin
if (ASeriesIndex > 0) and (chart.Series[ASeriesIndex-1].GroupIndex = ASeries.GroupIndex) then
isfirstOfGroup := false;
if (ASeriesIndex < chart.Series.Count-1) and (chart.Series[ASeriesIndex+1].GroupIndex = ASeries.GroupIndex) then
isLastOfGroup := false;
end;
if isFirstOfGroup then
AppendToStream(AStream, Format(
indent + '<c:areaChart>' + LE +
indent + ' <c:grouping val="%s"/>' + LE,
[ GROUPING[chart.StackMode] ]
));
WriteChartSeriesNode(AStream, AIndent + 2, ASeries, ASeriesIndex);
if isLastOfGroup then
begin
AppendToStream(AStream, Format(
indent + ' <c:axId val="%d"/>' + LE +
indent + ' <c:axId val="%d"/>' + LE +
indent + '</c:areaChart>' + LE,
[
FAxisID[ASeries.Chart.XAxis.Alignment], // <c:axId>
FAxisID[ASeries.Chart.YAxis.Alignment] // <c:axId>
]
));
end;
end;
{@@ ----------------------------------------------------------------------------
Writes the properties of the given bar series to the <c:plotArea> node of
file chartN.xml
-------------------------------------------------------------------------------}
procedure TsSpreadOOXMLChartWriter.WriteBarSeries(AStream: TStream;
AIndent: Integer; ASeries: TsBarSeries; ASeriesIndex: Integer);
const
GROUPING: Array[TsChartStackMode] of string = ('clustered', 'stacked', 'percentStacked');
var
indent: String;
chart: TsChart;
@ -3757,6 +3807,8 @@ begin
begin
ser := TsChartSeries(AChart.Series[i]);
case ser.ChartType of
ctArea:
WriteAreaSeries(AStream, AIndent + 2, TsAreaSeries(ser), i);
ctBar:
WriteBarSeries(AStream, AIndent + 2, TsBarSeries(ser), i);
ctScatter: