fpspreadsheet: Fix series fills and chart titles in ods writer.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8998 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-10-29 16:12:34 +00:00
parent fb8b6eef96
commit 2c8dac0888
2 changed files with 15 additions and 7 deletions

View File

@ -5,10 +5,11 @@ program write_chart_demo;
uses uses
SysUtils, fpspreadsheet, fpstypes, fpsUtils, fpschart, xlsxooxml, fpsopendocument; SysUtils, fpspreadsheet, fpstypes, fpsUtils, fpschart, xlsxooxml, fpsopendocument;
const const
SERIES_CLASS: TsChartSeriesClass = TsAreaSeries; // SERIES_CLASS: TsChartSeriesClass = TsAreaSeries;
// SERIES_CLASS: TsChartSeriesClass = TsBarSeries; // SERIES_CLASS: TsChartSeriesClass = TsBarSeries;
// SERIES_CLASS: TsChartSeriesClass = TsBubbleSeries; // SERIES_CLASS: TsChartSeriesClass = TsBubbleSeries;
// SERIES_CLASS: TsChartSeriesClass = TsLineSeries; SERIES_CLASS: TsChartSeriesClass = TsLineSeries;
// SERIES_CLASS: TsChartSeriesClass = TsScatterSeries;
r1 = 1; r1 = 1;
r2 = 8; r2 = 8;
FILL_COLORS: array[0..r2-r1] of TsColor = (scRed, scGreen, scBlue, scYellow, scMagenta, scSilver, scBlack, scOlive); FILL_COLORS: array[0..r2-r1] of TsColor = (scRed, scGreen, scBlue, scYellow, scMagenta, scSilver, scBlack, scOlive);
@ -99,7 +100,7 @@ begin
ch.Border.Style := clsSolid; ch.Border.Style := clsSolid;
ch.PlotArea.Background.Style := fsSolidFill; ch.PlotArea.Background.Style := fsSolidFill;
//ch.RotatedAxes := true; //ch.RotatedAxes := true;
ch.StackMode := csmStackedPercentage; //ch.StackMode := csmStackedPercentage;
//ch.Interpolation := ciCubicSpline; //ch.Interpolation := ciCubicSpline;
ch.XAxis.ShowLabels := true; ch.XAxis.ShowLabels := true;

View File

@ -48,7 +48,7 @@ type
procedure WriteChartSeries(AChartStream, AStyleStream: TStream; procedure WriteChartSeries(AChartStream, AStyleStream: TStream;
AChartIndent, AStyleIndent: Integer; AChart: TsChart; ASeriesIndex: Integer; AChartIndent, AStyleIndent: Integer; AChart: TsChart; ASeriesIndex: Integer;
var AStyleID: Integer); var AStyleID: Integer);
procedure WriteChartTable(AStream: TStream; AChart: TsChart; AIndent: Integer); // procedure WriteChartTable(AStream: TStream; AChart: TsChart; AIndent: Integer);
procedure WriteChartTitle(AChartStream, AStyleStream: TStream; procedure WriteChartTitle(AChartStream, AStyleStream: TStream;
AChartIndent, AStyleIndent: Integer; AChart: TsChart; IsSubtitle: Boolean; AChartIndent, AStyleIndent: Integer; AChart: TsChart; IsSubtitle: Boolean;
var AStyleID: Integer); var AStyleID: Integer);
@ -493,7 +493,7 @@ begin
lineser := TsLineSeries(series); lineser := TsLineSeries(series);
if lineser.ShowSymbols then if lineser.ShowSymbols then
chartProps := Format( chartProps := Format(
'chart:symbol-type="named-symbol" chart:symbol-name="%s" chart:symbol-width="%.1fmm" chart.symbol-height="%.1fmm" ', 'chart:symbol-type="named-symbol" chart:symbol-name="%s" chart:symbol-width="%.1fmm" chart:symbol-height="%.1fmm" ',
[CHART_SYMBOL_NAMES[lineSer.Symbol], lineSer.SymbolWidth, lineSer.SymbolHeight ], [CHART_SYMBOL_NAMES[lineSer.Symbol], lineSer.SymbolWidth, lineSer.SymbolHeight ],
FPointSeparatorSettings FPointSeparatorSettings
); );
@ -802,7 +802,8 @@ begin
AStream.CopyFrom(chartStream, chartStream.Size); AStream.CopyFrom(chartStream, chartStream.Size);
// After the chart elements we have the data to be plotted // After the chart elements we have the data to be plotted
WriteChartTable(AStream, AChart, 8); // WriteChartTable(AStream, AChart, 8);
// wp: writing this makes no change except the series fills not being applied
// Finally the footer. // Finally the footer.
AppendToStream(AStream, AppendToStream(AStream,
@ -1320,6 +1321,12 @@ begin
end; end;
end; end;
(* wp:
DO NOT DELETE THIS - IT WAS A PAINT TO GET THIS, AND MAYBE IT WILL BE NEEDED
LATER.
AT THE MOMENT THIS IS NOT NEEDED, IN FACT, IT IS EVEN DETRIMENTAL:
WITH THIS CODE INCLUDED, SERIES FILL ARE IGNORED AND TITLES ARE NOT CORRECT.
{ Writes the chart's data table. NOTE: The chart gets its data from this table { Writes the chart's data table. NOTE: The chart gets its data from this table
rather than from the worksheet! } rather than from the worksheet! }
procedure TsSpreadOpenDocChartWriter.WriteChartTable(AStream: TStream; procedure TsSpreadOpenDocChartWriter.WriteChartTable(AStream: TStream;
@ -1457,7 +1464,7 @@ begin
auxBook.Free; auxBook.Free;
end; end;
end; end;
*)
{ Writes the chart's title (or subtitle, depending on the value of IsSubTitle) { Writes the chart's title (or subtitle, depending on the value of IsSubTitle)
to the xml stream (chart stream) and the corresponding style to the stylestream. } to the xml stream (chart stream) and the corresponding style to the stylestream. }
procedure TsSpreadOpenDocChartWriter.WriteChartTitle(AChartStream, AStyleStream: TStream; procedure TsSpreadOpenDocChartWriter.WriteChartTitle(AChartStream, AStyleStream: TStream;