diff --git a/components/fpspreadsheet/examples/other/chart/write_chart_demo.lpr b/components/fpspreadsheet/examples/other/chart/write_chart_demo.lpr
index f5990c884..5dc2a3749 100644
--- a/components/fpspreadsheet/examples/other/chart/write_chart_demo.lpr
+++ b/components/fpspreadsheet/examples/other/chart/write_chart_demo.lpr
@@ -73,6 +73,7 @@ begin
ch.PlotArea.Background.Style := fsSolidFill;
//ch.RotatedAxes := true;
ch.StackMode := csmStackedPercentage;
+ //ch.Interpolation := ciCubicSpline;
ch.XAxis.ShowLabels := true;
ch.XAxis.LabelFont.Size := 9;
diff --git a/components/fpspreadsheet/laz_fpspreadsheet.lpk b/components/fpspreadsheet/laz_fpspreadsheet.lpk
index 97366824d..51533001b 100644
--- a/components/fpspreadsheet/laz_fpspreadsheet.lpk
+++ b/components/fpspreadsheet/laz_fpspreadsheet.lpk
@@ -33,7 +33,7 @@
This package is all you need if you don't want graphical components (such as grids and charts)."/>
-
+
@@ -299,16 +299,12 @@ This package is all you need if you don't want graphical components (such a
-
+
-
-
-
-
diff --git a/components/fpspreadsheet/source/common/fpschart.pas b/components/fpspreadsheet/source/common/fpschart.pas
index 518e64f3a..c7cf1cb9a 100644
--- a/components/fpspreadsheet/source/common/fpschart.pas
+++ b/components/fpspreadsheet/source/common/fpschart.pas
@@ -198,7 +198,6 @@ type
FLabelFormat: String;
FLine: TsChartLine;
FFill: TsChartFill;
- FBorder: TsChartLine;
public
constructor Create(AChart: TsChart); virtual;
destructor Destroy; override;
@@ -215,6 +214,7 @@ type
function LabelsInCol: Boolean;
function XValuesInCol: Boolean;
function YValuesInCol: Boolean;
+
property ChartType: TsChartType read FChartType;
property Count: Integer read GetCount;
property LabelFormat: String read FLabelFormat write FLabelFormat; // Number format in Excel notation, e.g. '0.00'
@@ -224,7 +224,6 @@ type
property YRange: TsCellRange read FYRange;
property YAxis: TsChartAxisLink read FYAxis write FYAxis;
- property Border: TsChartLine read FBorder write FBorder;
property Fill: TsChartFill read FFill write FFill;
property Line: TsChartLine read FLine write FLine;
end;
@@ -250,18 +249,20 @@ type
FSymbol: TsChartSeriesSymbol;
FSymbolHeight: Double; // in mm
FSymbolWidth: Double; // in mm
+ FShowLines: Boolean;
FShowSymbols: Boolean;
- function GetSymbolBorder: TsChartLine;
+ FBorder: TsChartLine;
function GetSymbolFill: TsChartFill;
- procedure SetSymbolBorder(Value: TsChartLine);
procedure SetSymbolFill(Value: TsChartFill);
public
constructor Create(AChart: TsChart); override;
+ destructor Destroy; override;
property Symbol: TsChartSeriesSymbol read FSymbol write FSymbol;
- property SymbolBorder: TsChartLine read GetSymbolBorder write SetSymbolBorder;
+ property SymbolBorder: TsChartLine read FBorder write FBorder;
property SymbolFill: TsChartFill read GetSymbolFill write SetSymbolFill;
property SymbolHeight: double read FSymbolHeight write FSymbolHeight;
property SymbolWidth: double read FSymbolWidth write FSymbolWidth;
+ property ShowLines: Boolean read FShowLines write FShowLines;
property ShowSymbols: Boolean read FShowSymbols write FShowSymbols;
end;
@@ -278,7 +279,12 @@ type
property Items[AIndex: Integer]: TsChartSeries read GetItem write SetItem; default;
end;
- TsChartStackMode =(csmSideBySide, csmStacked, csmStackedPercentage);
+ TsChartStackMode = (csmSideBySide, csmStacked, csmStackedPercentage);
+ TsChartInterpolation = (
+ ciLinear,
+ ciCubicSpline, ciBSpline,
+ ciStepStart, ciStepEnd, ciStepCenterX, ciStepCenterY
+ );
TsChart = class(TsChartFillElement)
private
@@ -295,8 +301,9 @@ type
FYAxis: TsChartAxis;
FY2Axis: TsChartAxis;
- FRotatedAxes: Boolean; // For bar series: vertical columns <--> horizontal bars
- FStackMode: TsChartStackMode;
+ FRotatedAxes: Boolean; // For bar series: vertical columns <--> horizontal bars
+ FStackMode: TsChartStackMode; // For bar and area series
+ FInterpolation: TsChartInterpolation; // For line/scatter series: data connection lines
FTitle: TsChartText;
FSubTitle: TsChartText;
@@ -316,12 +323,7 @@ type
function GetLineStyle(AIndex: Integer): TsChartLineStyle;
function IsScatterChart: Boolean;
function NumLineStyles: Integer;
- {
- function CategoriesInCol: Boolean;
- function CategoriesInRow: Boolean;
- function GetCategoryCount: Integer;
- function HasCategories: Boolean;
- }
+
{ Index of chart in workbook's chart list. }
property Index: Integer read FIndex write FIndex;
{ Index of worksheet sheet which contains the chart. }
@@ -364,9 +366,11 @@ type
{ Attributes of the plot's secondary y axis (right) }
property Y2Axis: TsChartAxis read FY2Axis write FY2Axis;
+ { Connecting line between data points (for line and scatter series) }
+ property Interpolation: TsChartInterpolation read FInterpolation write FInterpolation;
{ x and y axes exchanged (for bar series) }
property RotatedAxes: Boolean read FRotatedAxes write FRotatedAxes;
- { stacked series }
+ { Stacking of series (for bar and area series ) }
property StackMode: TsChartStackMode read FStackMode write FStackMode;
property CategoryLabelRange: TsCellRange read GetCategoryLabelRange;
@@ -573,11 +577,6 @@ begin
idx := AChart.AddSeries(self);
- FBorder := TsChartLine.Create;
- FBorder.Style := clsSolid;
- FBorder.Width := PtsToMM(DEFAULT_CHART_LINEWIDTH);
- FBorder.Color := scBlack;
-
FFill := TsChartFill.Create;
FFill.Style := fsSolidFill;
FFill.FgColor := DEFAULT_SERIES_COLORS[idx mod Length(DEFAULT_SERIES_COLORS)];
@@ -593,7 +592,6 @@ destructor TsChartSeries.Destroy;
begin
FLine.Free;
FFill.Free;
- FBorder.Free;
inherited;
end;
@@ -727,11 +725,19 @@ begin
FChartType := ctLine;
FSymbolWidth := 2.5;
FSymbolHeight := 2.5;
+ FShowSymbols := false;
+ FShowLines := true;
+
+ FBorder := TsChartLine.Create;
+ FBorder.Style := clsSolid;
+ FBorder.Width := PtsToMM(DEFAULT_CHART_LINEWIDTH);
+ FBorder.Color := scBlack;
end;
-function TsLineSeries.GetSymbolBorder: TsChartLine;
+destructor TsLineSeries.Destroy;
begin
- Result := FBorder;
+ FBorder.Free;
+ inherited;
end;
function TsLineSeries.GetSymbolFill: TsChartFill;
@@ -739,11 +745,6 @@ begin
Result := FFill;
end;
-procedure TsLineSeries.SetSymbolBorder(Value: TsChartLine);
-begin
- FBorder := Value;
-end;
-
procedure TsLineSeries.SetSymbolFill(Value: TsChartFill);
begin
FFill := Value;
diff --git a/components/fpspreadsheet/source/common/fpschartstyles.pas b/components/fpspreadsheet/source/common/fpschartstyles.pas
index 1d82096ad..9f140e256 100644
--- a/components/fpspreadsheet/source/common/fpschartstyles.pas
+++ b/components/fpspreadsheet/source/common/fpschartstyles.pas
@@ -336,7 +336,6 @@ begin
ceX2AxisMinorGrid: Result := AChart.X2Axis.MinorGridLines;
ceY2AxisMajorGrid: Result := AChart.Y2Axis.MajorGridLines;
ceY2AxisMinorGrid: Result := AChart.Y2Axis.MinorGridLines;
- ceSeriesBorder: Result := AChart.Series[AIndex].Border;
ceSeriesLine: Result := AChart.Series[AIndex].Line;
else
raise Exception.Create('[TsChartLineRec.GetChartLine] Line not supported.');
diff --git a/components/fpspreadsheet/source/common/fpsopendocument.pas b/components/fpspreadsheet/source/common/fpsopendocument.pas
index 963d5bcf8..51598d5cd 100644
--- a/components/fpspreadsheet/source/common/fpsopendocument.pas
+++ b/components/fpspreadsheet/source/common/fpsopendocument.pas
@@ -7151,6 +7151,7 @@ begin
series := AChart.Series[ASeriesIndex];
sheet := TsWorkbook(FWorkbook).GetWorksheetByIndex(AChart.sheetIndex);
+ // These are the x values of a scatter plot.
if series is TsScatterSeries then
begin
domainRange := GetSheetCellRangeString_ODS(
@@ -7161,12 +7162,15 @@ begin
);
end;
+ // These are the y values
valuesRange := GetSheetCellRangeString_ODS(
sheet.Name, sheet.Name,
series.YRange.Row1, series.YRange.Col1,
series.YRange.Row2, series.YRange.Col2,
rfAllRel, false
);
+
+ // And these are the data point labels.
titleAddr := GetSheetCellRangeString_ODS(
sheet.Name, sheet.Name,
series.TitleAddr.Row, series.TitleAddr.Col,
@@ -7174,7 +7178,7 @@ begin
rfAllRel, false);
count := series.YRange.Row2 - series.YRange.Row1 + 1;
- // Series properties
+ // Store the series properties
AppendToStream(AChartStream, Format(
indent + '' + LE +
indent + ' nil) then
+ if (series is TsLineSeries) then
begin
- if (lineSer.ShowSymbols) then
- graphProps := lineProps + fillProps
- else
- graphProps := lineProps;
- end;
+ if lineSer.ShowSymbols then
+ graphProps := graphProps + fillProps;
+ if lineSer.ShowLines and (lineser.Line.Style <> clsNoLine) then
+ graphProps := graphProps + lineProps;
+ end else
+ graphProps := fillProps + lineProps;
+ // Text properties
textProps := 'fo:font-size="10pt" style:font-size-asian="10pt" style:font-size-complex="10pt" ';
// textProps := WriteFontStyleXMLAsString(font); // <--- to be completed. this is for the series labels.