From 5f781b622ad5ffddeb79f2773b0c2d40c982d8e8 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Tue, 6 Feb 2024 15:53:19 +0000 Subject: [PATCH] fpspreadsheet: Supporting smooth scatter/line series for xlsx (less options than for ods) git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9219 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../examples/other/chart/scatter_write_demo.lpr | 5 ++++- .../fpspreadsheet/source/common/xlsxooxmlchart.pas | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/components/fpspreadsheet/examples/other/chart/scatter_write_demo.lpr b/components/fpspreadsheet/examples/other/chart/scatter_write_demo.lpr index 11b6e806e..f1a82980e 100644 --- a/components/fpspreadsheet/examples/other/chart/scatter_write_demo.lpr +++ b/components/fpspreadsheet/examples/other/chart/scatter_write_demo.lpr @@ -111,7 +111,10 @@ begin ch.YAxis.Logarithmic := true; end; end; - ch.XAxis.Inverted := true; + + // For testing: + // ch.XAxis.Inverted := true; + ch.Interpolation := ciCubicSpline; // Add scatter series ser := TsScatterSeries.Create(ch); diff --git a/components/fpspreadsheet/source/common/xlsxooxmlchart.pas b/components/fpspreadsheet/source/common/xlsxooxmlchart.pas index 6a1ce2458..db0a2afac 100644 --- a/components/fpspreadsheet/source/common/xlsxooxmlchart.pas +++ b/components/fpspreadsheet/source/common/xlsxooxmlchart.pas @@ -3964,14 +3964,25 @@ procedure TsSpreadOOXMLChartWriter.WriteScatterSeries(AStream: TStream; var indent: String; chart: TsChart; + scatterStyleStr: String; begin indent := DupeString(' ', AIndent); chart := ASeries.Chart; + case chart.Interpolation of + ciLinear: + scatterStyleStr := 'lineMarker'; + ciCubicSpline, ciBSpline: + scatterStyleStr := 'smoothMarker'; + else + //ciStepStart, ciStepEnd, ciCenterX, ciCenterY + scatterStyleStr := 'lineMarker'; // better than nothing... + end; + AppendToStream(AStream, indent + '' + LE + indent + ' ' + LE + - indent + ' ' + LE + indent + ' ' + LE ); WriteChartSeriesNode(AStream, AIndent + 4, ASeries, ASeriesIndex);