You've already forked lazarus-ccr
fpspreadsheet: different interpolation types for line and scatter plots.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8990 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -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;
|
||||
|
@ -33,7 +33,7 @@
|
||||
This package is all you need if you don't want graphical components (such as grids and charts)."/>
|
||||
<License Value="LGPL with static linking exception. This is the same license as is used in the LCL (Lazarus Component Library)."/>
|
||||
<Version Major="1" Minor="17"/>
|
||||
<Files Count="59">
|
||||
<Files Count="58">
|
||||
<Item1>
|
||||
<Filename Value="source\fps.inc"/>
|
||||
<Type Value="Include"/>
|
||||
@ -299,16 +299,12 @@ This package is all you need if you don't want graphical components (such a
|
||||
</Item56>
|
||||
<Item57>
|
||||
<Filename Value="source\common\fpschart.pas"/>
|
||||
<UnitName Value="fpschart"/>
|
||||
<UnitName Value="fpsChart"/>
|
||||
</Item57>
|
||||
<Item58>
|
||||
<Filename Value="source\common\fpspreadsheet_chart.inc"/>
|
||||
<Type Value="Binary"/>
|
||||
</Item58>
|
||||
<Item59>
|
||||
<Filename Value="source\common\fpschartstyles.pas"/>
|
||||
<UnitName Value="fpschartstyles"/>
|
||||
</Item59>
|
||||
</Files>
|
||||
<CompatibilityMode Value="True"/>
|
||||
<i18n>
|
||||
|
@ -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;
|
||||
|
@ -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.');
|
||||
|
@ -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 + '<chart:series chart:style-name="ch%d" ' +
|
||||
'chart:values-cell-range-address="%s" ' + // y values
|
||||
@ -7448,6 +7452,7 @@ function TsSpreadOpenDocWriter.GetChartPlotAreaStyleAsXML(AChart: TsChart;
|
||||
AIndent, AStyleID: Integer): String;
|
||||
var
|
||||
indent: String;
|
||||
interpolationStr: String = '';
|
||||
verticalStr: String = '';
|
||||
stackModeStr: String = '';
|
||||
begin
|
||||
@ -7455,15 +7460,27 @@ begin
|
||||
|
||||
if AChart.RotatedAxes then
|
||||
verticalStr := 'chart:vertical="true" ';
|
||||
|
||||
case AChart.StackMode of
|
||||
csmSideBySide: ;
|
||||
csmStacked: stackModeStr := 'chart:stacked="true" ';
|
||||
csmStackedPercentage: stackModeStr := 'chart:percentage="true" ';
|
||||
end;
|
||||
|
||||
case AChart.Interpolation of
|
||||
ciLinear: ;
|
||||
ciCubicSpline: interpolationStr := 'chart:interpolation="cubic-spline" ';
|
||||
ciBSpline: interpolationStr := 'chart:interpolation="b-spline" ';
|
||||
ciStepStart: interpolationStr := 'chart:interpolation="step-start" ';
|
||||
ciStepEnd: interpolationStr := 'chart:interpolation="step-end" ';
|
||||
ciStepCenterX: interpolationStr := 'chart:interpolation="step-center-x" ';
|
||||
ciStepCenterY: interpolationStr := 'chart:interpolation="step-center-y" ';
|
||||
end;
|
||||
|
||||
Result := Format(
|
||||
indent + ' <style:style style:name="ch%d" style:family="chart">' + LE +
|
||||
indent + ' <style:chart-properties ' +
|
||||
interpolationStr +
|
||||
verticalStr +
|
||||
stackModeStr +
|
||||
'chart:symbol-type="automatic" ' +
|
||||
@ -7502,13 +7519,13 @@ var
|
||||
textProps: String = '';
|
||||
lineProps: String = '';
|
||||
fillProps: String = '';
|
||||
s: String;
|
||||
begin
|
||||
Result := '';
|
||||
|
||||
indent := DupeString(' ', AIndent);
|
||||
series := AChart.Series[ASeriesIndex];
|
||||
|
||||
// Chart properties
|
||||
chartProps := 'chart:symbol-type="none" ';
|
||||
if (series is TsLineSeries) then
|
||||
begin
|
||||
@ -7522,16 +7539,19 @@ begin
|
||||
end;
|
||||
chartProps := chartProps + 'chart:link-data-style-to-source="true" ';
|
||||
|
||||
// Graphic properties
|
||||
lineProps := GetChartLineStyleGraphicPropsAsXML(AChart, series.Line);
|
||||
fillProps := GetChartFillStyleGraphicPropsAsXML(AChart, series.Fill);
|
||||
if (lineser <> 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.
|
||||
|
||||
|
Reference in New Issue
Block a user