You've already forked lazarus-ccr
fpspreadsheet: Chart link and ods reader support error bars (not complete, yet).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9099 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -347,26 +347,29 @@ type
|
|||||||
property Items[AIndex: Integer]: TsChartDataPointStyle read GetItem write SetItem; default;
|
property Items[AIndex: Integer]: TsChartDataPointStyle read GetItem write SetItem; default;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TsChartErrorBarKind = (cebkConstant, cebkPercentage, cebkStdDev, cebkRange);
|
TsChartErrorBarKind = (cebkConstant, cebkPercentage, cebkRange);
|
||||||
|
|
||||||
TsChartErrorBars = class(TsChartElement)
|
TsChartErrorBars = class(TsChartElement)
|
||||||
private
|
private
|
||||||
FKind: TsChartErrorBarKind;
|
FKind: TsChartErrorBarKind;
|
||||||
FLine: TsChartLine;
|
FLine: TsChartLine;
|
||||||
FValue: Array[0..1] of Double; // 0 = positive, 1 = negative error bar value
|
|
||||||
FRange: Array[0..1] of TsChartRange;
|
FRange: Array[0..1] of TsChartRange;
|
||||||
|
FValue: Array[0..1] of Double; // 0 = positive, 1 = negative error bar value
|
||||||
|
FShow: Array[0..1] of Boolean;
|
||||||
function GetRange(AIndex: Integer): TsChartRange;
|
function GetRange(AIndex: Integer): TsChartRange;
|
||||||
|
function GetShow(AIndex: Integer): Boolean;
|
||||||
function GetValue(AIndex: Integer): Double;
|
function GetValue(AIndex: Integer): Double;
|
||||||
procedure InternalSetErrorBarRange(AIndex: Integer;
|
procedure InternalSetErrorBarRange(AIndex: Integer;
|
||||||
ASheet1: String; ARow1, ACol1: Cardinal;
|
ASheet1: String; ARow1, ACol1: Cardinal;
|
||||||
ASheet2: String; ARow2, ACol2: Cardinal);
|
ASheet2: String; ARow2, ACol2: Cardinal);
|
||||||
procedure SetLine(AValue: TsChartLine);
|
procedure SetLine(AValue: TsChartLine);
|
||||||
procedure SetRange(AIndex: Integer; AValue: TsChartRange);
|
procedure SetRange(AIndex: Integer; AValue: TsChartRange);
|
||||||
|
procedure SetShow(AIndex: Integer; AValue: Boolean);
|
||||||
procedure SetValue(AIndex: Integer; AValue: Double);
|
procedure SetValue(AIndex: Integer; AValue: Double);
|
||||||
public
|
public
|
||||||
constructor Create(AChart: TsChart);
|
constructor Create(AChart: TsChart);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure CopyFrom(ASource: TsChartElement);
|
procedure CopyFrom(ASource: TsChartElement); override;
|
||||||
procedure SetErrorBarRangePos(ARow1, ACol1, ARow2, ACol2: Cardinal);
|
procedure SetErrorBarRangePos(ARow1, ACol1, ARow2, ACol2: Cardinal);
|
||||||
procedure SetErrorBarRangePos(ASheet1: String; ARow1, ACol1: Cardinal; ASheet2: String; ARow2, ACol2: Cardinal);
|
procedure SetErrorBarRangePos(ASheet1: String; ARow1, ACol1: Cardinal; ASheet2: String; ARow2, ACol2: Cardinal);
|
||||||
procedure SetErrorBarRangeNeg(ARow1, ACol1, ARow2, ACol2: Cardinal);
|
procedure SetErrorBarRangeNeg(ARow1, ACol1, ARow2, ACol2: Cardinal);
|
||||||
@ -375,6 +378,8 @@ type
|
|||||||
property Line: TsChartLine read FLine write SetLine;
|
property Line: TsChartLine read FLine write SetLine;
|
||||||
property RangePos: TsChartRange index 0 read GetRange write SetRange;
|
property RangePos: TsChartRange index 0 read GetRange write SetRange;
|
||||||
property RangeNeg: TsChartRange index 1 read GetRange write SetRange;
|
property RangeNeg: TsChartRange index 1 read GetRange write SetRange;
|
||||||
|
property ShowPos: Boolean index 0 read GetShow write SetShow;
|
||||||
|
property ShowNeg: Boolean index 1 read GetShow write SetShow;
|
||||||
property ValuePos: Double index 0 read GetValue write SetValue;
|
property ValuePos: Double index 0 read GetValue write SetValue;
|
||||||
property ValueNeg: Double index 1 read GetValue write SetValue;
|
property ValueNeg: Double index 1 read GetValue write SetValue;
|
||||||
end;
|
end;
|
||||||
@ -398,13 +403,14 @@ type
|
|||||||
FLabelFormat: String;
|
FLabelFormat: String;
|
||||||
FDataLabels: TsChartDataLabels;
|
FDataLabels: TsChartDataLabels;
|
||||||
FDataPointStyles: TsChartDataPointStyleList;
|
FDataPointStyles: TsChartDataPointStyleList;
|
||||||
FErrorBars: TsChartErrorBars;
|
FXErrorBars: TsChartErrorBars;
|
||||||
procedure SetErrorBars(AValue: TsChartErrorBars);
|
FYErrorBars: TsChartErrorBars;
|
||||||
|
procedure SetXErrorBars(AValue: TsChartErrorBars);
|
||||||
|
procedure SetYErrorBars(AValue: TsChartErrorBars);
|
||||||
protected
|
protected
|
||||||
FLine: TsChartLine;
|
FLine: TsChartLine;
|
||||||
FFill: TsChartFill;
|
FFill: TsChartFill;
|
||||||
function GetChartType: TsChartType; virtual;
|
function GetChartType: TsChartType; virtual;
|
||||||
property ErrorBars: TsChartErrorBars read FErrorBars write SetErrorBars;
|
|
||||||
public
|
public
|
||||||
constructor Create(AChart: TsChart); virtual;
|
constructor Create(AChart: TsChart); virtual;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -445,8 +451,10 @@ type
|
|||||||
property LineColorRange: TsChartRange read FLineColorRange write FLineColorRange;
|
property LineColorRange: TsChartRange read FLineColorRange write FLineColorRange;
|
||||||
property TitleAddr: TsChartCellAddr read FTitleAddr write FTitleAddr; // use '\n' for line-break
|
property TitleAddr: TsChartCellAddr read FTitleAddr write FTitleAddr; // use '\n' for line-break
|
||||||
property XAxis: TsChartAxisLink read FXAxis write FXAxis;
|
property XAxis: TsChartAxisLink read FXAxis write FXAxis;
|
||||||
|
property XErrorBars: TsChartErrorBars read FXErrorBars write SetXErrorBars;
|
||||||
property XRange: TsChartRange read FXRange write FXRange;
|
property XRange: TsChartRange read FXRange write FXRange;
|
||||||
property YAxis: TsChartAxisLink read FYAxis write FYAxis;
|
property YAxis: TsChartAxisLink read FYAxis write FYAxis;
|
||||||
|
property YErrorBars: TsChartErrorBars read FYErrorBars write SetYErrorBars;
|
||||||
property YRange: TsChartRange read FYRange write FYRange;
|
property YRange: TsChartRange read FYRange write FYRange;
|
||||||
|
|
||||||
property Fill: TsChartFill read FFill write FFill;
|
property Fill: TsChartFill read FFill write FFill;
|
||||||
@ -457,13 +465,11 @@ type
|
|||||||
TsAreaSeries = class(TsChartSeries)
|
TsAreaSeries = class(TsChartSeries)
|
||||||
public
|
public
|
||||||
constructor Create(AChart: TsChart); override;
|
constructor Create(AChart: TsChart); override;
|
||||||
property ErrorBars;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TsBarSeries = class(TsChartSeries)
|
TsBarSeries = class(TsChartSeries)
|
||||||
public
|
public
|
||||||
constructor Create(AChart: TsChart); override;
|
constructor Create(AChart: TsChart); override;
|
||||||
property ErrorBars;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TsChartSeriesSymbol = (
|
TsChartSeriesSymbol = (
|
||||||
@ -496,7 +502,6 @@ type
|
|||||||
|
|
||||||
TsLineSeries = class(TsCustomLineSeries)
|
TsLineSeries = class(TsCustomLineSeries)
|
||||||
public
|
public
|
||||||
property ErrorBars;
|
|
||||||
property Symbol;
|
property Symbol;
|
||||||
property SymbolBorder;
|
property SymbolBorder;
|
||||||
property SymbolFill;
|
property SymbolFill;
|
||||||
@ -575,7 +580,6 @@ type
|
|||||||
|
|
||||||
TsScatterSeries = class(TsCustomScatterSeries)
|
TsScatterSeries = class(TsCustomScatterSeries)
|
||||||
public
|
public
|
||||||
property ErrorBars;
|
|
||||||
property Symbol;
|
property Symbol;
|
||||||
property SymbolBorder;
|
property SymbolBorder;
|
||||||
property SymbolFill;
|
property SymbolFill;
|
||||||
@ -1561,6 +1565,8 @@ begin
|
|||||||
FLine.Color := scBlack;
|
FLine.Color := scBlack;
|
||||||
FRange[0] := TsChartRange.Create(AChart);
|
FRange[0] := TsChartRange.Create(AChart);
|
||||||
FRange[1] := TsChartRange.Create(AChart);
|
FRange[1] := TsChartRange.Create(AChart);
|
||||||
|
FShow[0] := true;
|
||||||
|
FShow[1] := true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TsChartErrorBars.Destroy;
|
destructor TsChartErrorBars.Destroy;
|
||||||
@ -1576,12 +1582,14 @@ begin
|
|||||||
inherited CopyFrom(ASource);
|
inherited CopyFrom(ASource);
|
||||||
if ASource is TsChartErrorBars then
|
if ASource is TsChartErrorBars then
|
||||||
begin
|
begin
|
||||||
FLine.CopyFrom(TsChartErrorBars(ASource).Line);
|
FKind := TsChartErrorBars(ASource).Kind;
|
||||||
FRange[0].CopyFrom(TsChartErrorBars(ASource).RangePos);
|
FRange[0].CopyFrom(TsChartErrorBars(ASource).RangePos);
|
||||||
FRange[1].CopyFrom(TsChartErrorBars(ASource).RangeNeg);
|
FRange[1].CopyFrom(TsChartErrorBars(ASource).RangeNeg);
|
||||||
|
FShow[0] := TsChartErrorBars(ASource).ShowPos;
|
||||||
|
FShow[1] := TsChartErrorBars(ASource).ShowNeg;
|
||||||
FValue[0] := TsChartErrorBars(ASource).ValuePos;
|
FValue[0] := TsChartErrorBars(ASource).ValuePos;
|
||||||
FValue[1] := TsChartErrorBars(ASource).ValueNeg;
|
FValue[1] := TsChartErrorBars(ASource).ValueNeg;
|
||||||
FKind := TsChartErrorBars(ASource).Kind;
|
FLine.CopyFrom(TsChartErrorBars(ASource).Line);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1590,6 +1598,11 @@ begin
|
|||||||
Result := FRange[AIndex];
|
Result := FRange[AIndex];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TsChartErrorBars.GetShow(AIndex: Integer): Boolean;
|
||||||
|
begin
|
||||||
|
Result := FShow[AIndex];
|
||||||
|
end;
|
||||||
|
|
||||||
function TsChartErrorBars.GetValue(AIndex: Integer): Double;
|
function TsChartErrorBars.GetValue(AIndex: Integer): Double;
|
||||||
begin
|
begin
|
||||||
result := FValue[AIndex];
|
result := FValue[AIndex];
|
||||||
@ -1641,6 +1654,11 @@ begin
|
|||||||
FRange[AIndex].CopyFrom(AValue);
|
FRange[AIndex].CopyFrom(AValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TsChartErrorBars.SetShow(AIndex: Integer; AValue: Boolean);
|
||||||
|
begin
|
||||||
|
FShow[AIndex] := AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TsChartErrorBars.SetValue(AIndex: Integer; AValue: Double);
|
procedure TsChartErrorBars.SetValue(AIndex: Integer; AValue: Double);
|
||||||
begin
|
begin
|
||||||
FValue[AIndex] := AValue;
|
FValue[AIndex] := AValue;
|
||||||
@ -1690,12 +1708,14 @@ begin
|
|||||||
|
|
||||||
FLabelSeparator := ' ';
|
FLabelSeparator := ' ';
|
||||||
|
|
||||||
FErrorBars := TsChartErrorBars.Create(AChart);
|
FXErrorBars := TsChartErrorBars.Create(AChart);
|
||||||
|
FYErrorBars := TsChartErrorBars.Create(AChart);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TsChartSeries.Destroy;
|
destructor TsChartSeries.Destroy;
|
||||||
begin
|
begin
|
||||||
FErrorBars.Free;
|
FYErrorBars.Free;
|
||||||
|
FXErrorBars.Free;
|
||||||
FLabelBackground.Free;
|
FLabelBackground.Free;
|
||||||
FLabelBorder.Free;
|
FLabelBorder.Free;
|
||||||
FLabelFont.Free;
|
FLabelFont.Free;
|
||||||
@ -1760,11 +1780,6 @@ begin
|
|||||||
Result := (FLabelRange.Col1 = FLabelRange.Col2) and (FLabelRange.Row1 <> FLabelRange.Row2);
|
Result := (FLabelRange.Col1 = FLabelRange.Col2) and (FLabelRange.Row1 <> FLabelRange.Row2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TsChartSeries.SetErrorBars(AValue: TsChartErrorBars);
|
|
||||||
begin
|
|
||||||
FErrorBars.CopyFrom(AValue);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TsChartSeries.SetTitleAddr(ARow, ACol: Cardinal);
|
procedure TsChartSeries.SetTitleAddr(ARow, ACol: Cardinal);
|
||||||
begin
|
begin
|
||||||
SetTitleAddr('', ARow, ACol);
|
SetTitleAddr('', ARow, ACol);
|
||||||
@ -1831,6 +1846,11 @@ begin
|
|||||||
FLineColorRange.Col2 := ACol2;
|
FLineColorRange.Col2 := ACol2;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TsChartSeries.SetXErrorBars(AValue: TsChartErrorBars);
|
||||||
|
begin
|
||||||
|
FXErrorBars.CopyFrom(AValue);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TsChartSeries.SetXRange(ARow1, ACol1, ARow2, ACol2: Cardinal);
|
procedure TsChartSeries.SetXRange(ARow1, ACol1, ARow2, ACol2: Cardinal);
|
||||||
begin
|
begin
|
||||||
SetXRange('', ARow1, ACol1, '', ARow2, ACol2);
|
SetXRange('', ARow1, ACol1, '', ARow2, ACol2);
|
||||||
@ -1849,6 +1869,11 @@ begin
|
|||||||
FXRange.Col2 := ACol2;
|
FXRange.Col2 := ACol2;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TsChartSeries.SetYErrorBars(AValue: TsChartErrorBars);
|
||||||
|
begin
|
||||||
|
FYErrorBars.CopyFrom(AValue);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TsChartSeries.SetYRange(ARow1, ACol1, ARow2, ACol2: Cardinal);
|
procedure TsChartSeries.SetYRange(ARow1, ACol1, ARow2, ACol2: Cardinal);
|
||||||
begin
|
begin
|
||||||
SetYRange('', ARow1, ACol1, '', ARow2, ACol2);
|
SetYRange('', ARow1, ACol1, '', ARow2, ACol2);
|
||||||
|
@ -50,6 +50,10 @@ type
|
|||||||
procedure ReadChartRegressionStyle(AStyleNode: TDOMNode; AChart: TsChart; ASeries: TsChartSeries);
|
procedure ReadChartRegressionStyle(AStyleNode: TDOMNode; AChart: TsChart; ASeries: TsChartSeries);
|
||||||
procedure ReadChartSeriesDataPointStyle(AStyleNode: TDOMNode; AChart: TsChart;
|
procedure ReadChartSeriesDataPointStyle(AStyleNode: TDOMNode; AChart: TsChart;
|
||||||
ASeries: TsChartSeries; var AFill: TsChartFill; var ALine: TsChartLine);
|
ASeries: TsChartSeries; var AFill: TsChartFill; var ALine: TsChartLine);
|
||||||
|
procedure ReadChartSeriesErrorBarProps(ANode, AStyleNode: TDOMNode; AChart: TsChart;
|
||||||
|
ASeries: TsChartSeries);
|
||||||
|
procedure ReadChartSeriesErrorBarStyle(AStyleNode: TDOMNode; AChart: TsChart;
|
||||||
|
AErrorBars: TsChartErrorBars);
|
||||||
procedure ReadChartSeriesProps(ANode, AStyleNode: TDOMNode; AChart: TsChart);
|
procedure ReadChartSeriesProps(ANode, AStyleNode: TDOMNode; AChart: TsChart);
|
||||||
procedure ReadChartSeriesStyle(AStyleNode: TDOMNode; AChart: TsChart; ASeries: TsChartSeries);
|
procedure ReadChartSeriesStyle(AStyleNode: TDOMNode; AChart: TsChart; ASeries: TsChartSeries);
|
||||||
procedure ReadChartStockSeriesStyle(AStyleNode: TDOMNode; AChart: TsChart;
|
procedure ReadChartStockSeriesStyle(AStyleNode: TDOMNode; AChart: TsChart;
|
||||||
@ -1305,6 +1309,83 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TsSpreadOpenDocChartReader.ReadChartSeriesErrorBarProps(
|
||||||
|
ANode, AStyleNode: TDOMNode; AChart: TsChart; ASeries: TsChartSeries);
|
||||||
|
var
|
||||||
|
s: String;
|
||||||
|
styleNode: TDOMNode;
|
||||||
|
errorBars: TsChartErrorBars;
|
||||||
|
begin
|
||||||
|
s := GetAttrValue(ANode, 'chart:dimension');
|
||||||
|
case s of
|
||||||
|
'x': errorBars := ASeries.XErrorBars;
|
||||||
|
'y': errorBars := ASeries.YErrorBars;
|
||||||
|
else exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
s := GetAttrValue(ANode, 'chart:style-name');
|
||||||
|
if s <> '' then
|
||||||
|
begin
|
||||||
|
styleNode := FindStyleNode(AStyleNode, s);
|
||||||
|
ReadChartSeriesErrorBarStyle(styleNode, AChart, errorBars);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TsSpreadOpenDocChartReader.ReadChartSeriesErrorBarStyle(
|
||||||
|
AStyleNode: TDOMNode; AChart: TsChart; AErrorBars: TsChartErrorBars);
|
||||||
|
var
|
||||||
|
nodeName, s: String;
|
||||||
|
x: Double;
|
||||||
|
begin
|
||||||
|
AStyleNode := AStyleNode.FirstChild;
|
||||||
|
while AStyleNode <> nil do
|
||||||
|
begin
|
||||||
|
nodeName := AStyleNode.NodeName;
|
||||||
|
case nodeName of
|
||||||
|
'style:chart-properties':
|
||||||
|
begin
|
||||||
|
s := GetAttrValue(AStyleNode, 'chart:error-category');
|
||||||
|
case s of
|
||||||
|
'constant': AErrorBars.Kind := cebkConstant;
|
||||||
|
'cell-range': AErrorBars.Kind := cebkRange;
|
||||||
|
'percentage': AErrorBars.Kind := cebkPercentage;
|
||||||
|
else
|
||||||
|
exit;
|
||||||
|
// To do: support the statistical categories 'standard-error',
|
||||||
|
// 'variance', 'standard-deviation', 'error-margin'
|
||||||
|
end;
|
||||||
|
|
||||||
|
s := GetAttrValue(AStyleNode, 'chart:error-lower-limit');
|
||||||
|
if (s <> '') and TryStrToFloat(s, x, FPointSeparatorSettings) then
|
||||||
|
AErrorBars.ValueNeg := x;
|
||||||
|
|
||||||
|
s := GetAttrValue(AStyleNode, 'chart:error-upper-limit');
|
||||||
|
if (s <> '') and TryStrToFloat(s, x, FPointSeparatorSettings) then
|
||||||
|
AErrorBars.ValuePos := x;
|
||||||
|
|
||||||
|
s := GetAttrValue(AStyleNode, 'chart:error-lower-indicator');
|
||||||
|
AErrorBars.ShowNeg := (s = 'true');
|
||||||
|
|
||||||
|
s := GetAttrValue(AStyleNode, 'chart:error-upper-indicator');
|
||||||
|
AErrorBars.ShowPos := (s = 'true');
|
||||||
|
|
||||||
|
s := GetAttrValue(AStyleNode, 'chart:error-percentage');
|
||||||
|
if (s <> '') and TryStrToFloat(s, x, FPointSeparatorSettings) then
|
||||||
|
begin
|
||||||
|
AErrorBars.ValueNeg := x;
|
||||||
|
AErrorBars.ValuePos := x;
|
||||||
|
end;
|
||||||
|
|
||||||
|
ReadChartCellRange(AStyleNode, 'chart:error-lower-range', AErrorBars.RangeNeg);
|
||||||
|
ReadChartCellRange(AStyleNode, 'chart:error-upper-range', AErrorBars.RangePos);
|
||||||
|
end;
|
||||||
|
'style:graphic-properties':
|
||||||
|
GetChartLineProps(AStyleNode, AChart, AErrorBars.Line);
|
||||||
|
end;
|
||||||
|
AStyleNode := AStyleNode.NextSibling;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TsSpreadOpenDocChartReader.ReadChartSeriesProps(ANode, AStyleNode: TDOMNode;
|
procedure TsSpreadOpenDocChartReader.ReadChartSeriesProps(ANode, AStyleNode: TDOMNode;
|
||||||
AChart: TsChart);
|
AChart: TsChart);
|
||||||
var
|
var
|
||||||
@ -1414,6 +1495,8 @@ begin
|
|||||||
fill.Free; // the styles have been copied to the series datapoint list and are not needed any more.
|
fill.Free; // the styles have been copied to the series datapoint list and are not needed any more.
|
||||||
line.Free;
|
line.Free;
|
||||||
end;
|
end;
|
||||||
|
'chart:error-indicator':
|
||||||
|
ReadChartSeriesErrorbarProps(subNode, AStyleNode, AChart, series);
|
||||||
end;
|
end;
|
||||||
subnode := subNode.NextSibling;
|
subnode := subNode.NextSibling;
|
||||||
end;
|
end;
|
||||||
|
@ -41,7 +41,7 @@ type
|
|||||||
|
|
||||||
{ TsWorkbookChartSource }
|
{ TsWorkbookChartSource }
|
||||||
|
|
||||||
TsXYLRange = (rngX, rngY, rngLabel, rngColor);
|
TsXYLRange = (rngX, rngY, rngLabel, rngColor, rngXErrors, rngYErrors);
|
||||||
|
|
||||||
TsWorkbookChartSource = class(TCustomChartSource, IsSpreadsheetControl)
|
TsWorkbookChartSource = class(TCustomChartSource, IsSpreadsheetControl)
|
||||||
private
|
private
|
||||||
@ -85,6 +85,8 @@ type
|
|||||||
procedure SetXRange(XIndex: Integer; ARange: TsChartRange);
|
procedure SetXRange(XIndex: Integer; ARange: TsChartRange);
|
||||||
procedure SetYRange(YIndex: Integer; ARange: TsChartRange);
|
procedure SetYRange(YIndex: Integer; ARange: TsChartRange);
|
||||||
procedure SetTitleAddr(Addr: TsChartCellAddr);
|
procedure SetTitleAddr(Addr: TsChartCellAddr);
|
||||||
|
procedure SetXErrorBarRange(ARange: TsChartRange);
|
||||||
|
procedure SetYErrorBarRange(ARange: TsChartRange);
|
||||||
procedure UseDataPointColors(ASeries: TsChartSeries);
|
procedure UseDataPointColors(ASeries: TsChartSeries);
|
||||||
property PointsNumber: Cardinal read FPointsNumber;
|
property PointsNumber: Cardinal read FPointsNumber;
|
||||||
property Workbook: TsWorkbook read GetWorkbook;
|
property Workbook: TsWorkbook read GetWorkbook;
|
||||||
@ -98,9 +100,14 @@ type
|
|||||||
property CyclicX: Boolean read FCyclicX write FCyclicX default false;
|
property CyclicX: Boolean read FCyclicX write FCyclicX default false;
|
||||||
property IntegerX: Boolean read FIntegerX write FIntegerX default false;
|
property IntegerX: Boolean read FIntegerX write FIntegerX default false;
|
||||||
property LabelRange: String index rngLabel read GetRange write SetRange;
|
property LabelRange: String index rngLabel read GetRange write SetRange;
|
||||||
|
property XErrorBarRange: String index rngXErrors read GetRange write SetRange;
|
||||||
|
property YErrorBarRange: String index rngYErrors read GetRange write SetRange;
|
||||||
property XRange: String index rngX read GetRange write SetRange;
|
property XRange: String index rngX read GetRange write SetRange;
|
||||||
property YRange: String index rngY read GetRange write SetRange;
|
property YRange: String index rngY read GetRange write SetRange;
|
||||||
property Title: String read GetTitle;
|
property Title: String read GetTitle;
|
||||||
|
|
||||||
|
property XErrorBarData;
|
||||||
|
property YErrorBarData;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{@@ Link between TAChart and the fpspreadsheet chart class }
|
{@@ Link between TAChart and the fpspreadsheet chart class }
|
||||||
@ -148,6 +155,7 @@ type
|
|||||||
procedure UpdateChartBackground(AWorkbookChart: TsChart);
|
procedure UpdateChartBackground(AWorkbookChart: TsChart);
|
||||||
// procedure UpdateBarSeries(AWorkbookChart: TsChart);
|
// procedure UpdateBarSeries(AWorkbookChart: TsChart);
|
||||||
procedure UpdateChartBrush(AWorkbookChart: TsChart; AWorkbookFill: TsChartFill; ABrush: TBrush);
|
procedure UpdateChartBrush(AWorkbookChart: TsChart; AWorkbookFill: TsChartFill; ABrush: TBrush);
|
||||||
|
procedure UpdateChartErrorBars(AWorkbookSeries: TsChartSeries; ASeries: TBasicPointSeries);
|
||||||
procedure UpdateChartLegend(AWorkbookLegend: TsChartLegend; ALegend: TChartLegend);
|
procedure UpdateChartLegend(AWorkbookLegend: TsChartLegend; ALegend: TChartLegend);
|
||||||
procedure UpdateChartPen(AWorkbookChart: TsChart; AWorkbookLine: TsChartLine; APen: TPen);
|
procedure UpdateChartPen(AWorkbookChart: TsChart; AWorkbookLine: TsChartLine; APen: TPen);
|
||||||
procedure UpdateChartSeriesMarks(AWorkbookSeries: TsChartSeries; AChartSeries: TChartSeries);
|
procedure UpdateChartSeriesMarks(AWorkbookSeries: TsChartSeries; AChartSeries: TChartSeries);
|
||||||
@ -177,7 +185,6 @@ type
|
|||||||
property Chart: TChart read FChart write SetChart;
|
property Chart: TChart read FChart write SetChart;
|
||||||
property WorkbookChartIndex: Integer read FWorkbookChartIndex write SetWorkbookChartIndex;
|
property WorkbookChartIndex: Integer read FWorkbookChartIndex write SetWorkbookChartIndex;
|
||||||
property WorkbookSource: TsWorkbookSource read FWorkbookSource write SetWorkbookSource;
|
property WorkbookSource: TsWorkbookSource read FWorkbookSource write SetWorkbookSource;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure Convert_sChartLine_to_Pen(AChart: TsChart; ALine: TsChartLine; APen: TPen);
|
procedure Convert_sChartLine_to_Pen(AChart: TsChart; ALine: TsChartLine; APen: TPen);
|
||||||
@ -910,11 +917,21 @@ begin
|
|||||||
FTitleSheetName := Addr.GetSheetName;
|
FTitleSheetName := Addr.GetSheetName;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TsWorkbookChartSource.SetXErrorBarRange(ARange: TsChartRange);
|
||||||
|
begin
|
||||||
|
SetRangeFromChart(rngXErrors, 0, ARange);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TsWorkbookChartSource.SetXRange(XIndex: Integer; ARange: TsChartRange);
|
procedure TsWorkbookChartSource.SetXRange(XIndex: Integer; ARange: TsChartRange);
|
||||||
begin
|
begin
|
||||||
SetRangeFromChart(rngX, XIndex, ARange);
|
SetRangeFromChart(rngX, XIndex, ARange);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TsWorkbookChartSource.SetYErrorBarRange(ARange: TsChartRange);
|
||||||
|
begin
|
||||||
|
SetRangeFromChart(rngYErrors, 0, ARange);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TsWorkbookChartSource.SetYRange(YIndex: Integer; ARange: TsChartRange);
|
procedure TsWorkbookChartSource.SetYRange(YIndex: Integer; ARange: TsChartRange);
|
||||||
begin
|
begin
|
||||||
SetRangeFromChart(rngY, YIndex, ARange);
|
SetRangeFromChart(rngY, YIndex, ARange);
|
||||||
@ -1686,6 +1703,7 @@ begin
|
|||||||
AChartSeries.UseZeroLevel := true;
|
AChartSeries.UseZeroLevel := true;
|
||||||
if AChartSeries.Source is TCalculatedChartSource then
|
if AChartSeries.Source is TCalculatedChartSource then
|
||||||
TCalculatedChartSource(AChartSeries.Source).Percentage := (AWorkbookSeries.Chart.StackMode = csmStackedPercentage);
|
TCalculatedChartSource(AChartSeries.Source).Percentage := (AWorkbookSeries.Chart.StackMode = csmStackedPercentage);
|
||||||
|
UpdateChartErrorBars(AWorkbookSeries, AChartSeries);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TsWorkbookChartLink.UpdateBarSeries(AWorkbookSeries: TsBarSeries;
|
procedure TsWorkbookChartLink.UpdateBarSeries(AWorkbookSeries: TsBarSeries;
|
||||||
@ -1697,6 +1715,7 @@ begin
|
|||||||
AChartSeries.Stacked := AWorkbookSeries.Chart.StackMode <> csmSideBySide;
|
AChartSeries.Stacked := AWorkbookSeries.Chart.StackMode <> csmSideBySide;
|
||||||
if AChartSeries.Source is TCalculatedChartSource then
|
if AChartSeries.Source is TCalculatedChartSource then
|
||||||
TCalculatedChartSource(AChartSeries.Source).Percentage := (AWorkbookSeries.Chart.StackMode = csmStackedPercentage);
|
TCalculatedChartSource(AChartSeries.Source).Percentage := (AWorkbookSeries.Chart.StackMode = csmStackedPercentage);
|
||||||
|
UpdateChartErrorBars(AWorkbookSeries, AChartSeries);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TsWorkbookChartlink.UpdateBubbleSeries(AWorkbookSeries: TsBubbleSeries;
|
procedure TsWorkbookChartlink.UpdateBubbleSeries(AWorkbookSeries: TsBubbleSeries;
|
||||||
@ -1970,6 +1989,63 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
type
|
||||||
|
TErrorbarSeries = class(TBasicPointSeries)
|
||||||
|
public
|
||||||
|
property XErrorBars;
|
||||||
|
property YErrorBars;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TsWorkbookChartLink.UpdateChartErrorBars(AWorkbookSeries: TsChartSeries;
|
||||||
|
ASeries: TBasicPointSeries);
|
||||||
|
const
|
||||||
|
ERRORBAR_KINDS: array[TsChartErrorBarKind] of TChartErrorBarKind = (
|
||||||
|
ebkConst, ebkPercent, ebkChartSource);
|
||||||
|
|
||||||
|
function GetChartSource(ASource: TCustomChartSource): TsWorkbookChartSource;
|
||||||
|
begin
|
||||||
|
if ASource is TsWorkbookChartSource then
|
||||||
|
Result := TsWorkbookChartSource(ASource)
|
||||||
|
else if (ASource is TCalculatedChartSource) then
|
||||||
|
Result := GetChartSource(TCalculatedChartSource(ASource).Origin)
|
||||||
|
else
|
||||||
|
Result := nil;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
series: TErrorBarSeries;
|
||||||
|
source: TsWorkbookChartSource;
|
||||||
|
begin
|
||||||
|
source := GetChartSource(ASeries.Source);
|
||||||
|
if source = nil then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
series := TErrorBarSeries(ASeries);
|
||||||
|
|
||||||
|
series.XErrorBars.Visible := AWorkbookSeries.XErrorBars.ShowPos or AWorkbookSeries.XErrorBars.ShowNeg;;
|
||||||
|
series.YErrorBars.Visible := AWorkbookSeries.YErrorBars.ShowPos or AWorkbookSeries.YErrorBars.ShowNeg;;
|
||||||
|
|
||||||
|
UpdateChartPen(AWorkbookSeries.Chart, AWorkbookSeries.XErrorBars.Line, series.XErrorBars.Pen);
|
||||||
|
UpdateChartPen(AWorkbookSeries.Chart, AWorkbookSeries.YErrorBars.Line, series.YErrorBars.Pen);
|
||||||
|
|
||||||
|
source.XErrorBarData.Kind := ERRORBAR_KINDS[AWorkbookSeries.XErrorBars.Kind];
|
||||||
|
source.YErrorBarData.Kind := ERRORBAR_KINDS[AWorkbookSeries.YErrorBars.Kind];
|
||||||
|
|
||||||
|
source.XErrorBarData.ValuePlus := AWorkbookSeries.XErrorBars.ValuePos;
|
||||||
|
source.YErrorBarData.ValuePlus := AWorkbookSeries.YErrorBars.ValuePos;
|
||||||
|
|
||||||
|
source.XErrorBarData.ValueMinus := AWorkbookSeries.XErrorBars.ValueNeg;
|
||||||
|
source.YErrorBarData.ValueMinus := AWorkbookSeries.YErrorBars.ValueNeg;
|
||||||
|
|
||||||
|
{ To do: pass the cell range to the workbookchartsource. There's a problem
|
||||||
|
with the following code that TAChart assumes the error values to be stored
|
||||||
|
in additional x and y values of the TChartDataItem...
|
||||||
|
|
||||||
|
if AWorkbookSeries.XErrorBars.Kind = cebkRange then
|
||||||
|
source.SetXErrorBarRange(AWorkbookSeries.XErrorBars.Range
|
||||||
|
}
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TsWorkbookChartLink.UpdateChartLegend(AWorkbookLegend: TsChartLegend;
|
procedure TsWorkbookChartLink.UpdateChartLegend(AWorkbookLegend: TsChartLegend;
|
||||||
ALegend: TChartLegend);
|
ALegend: TChartLegend);
|
||||||
const
|
const
|
||||||
@ -2156,6 +2232,8 @@ begin
|
|||||||
AChartSeries.Stacked := AWorkbookSeries.Chart.StackMode <> csmSideBySide;
|
AChartSeries.Stacked := AWorkbookSeries.Chart.StackMode <> csmSideBySide;
|
||||||
if AChartSeries.Source is TCalculatedChartSource then
|
if AChartSeries.Source is TCalculatedChartSource then
|
||||||
TCalculatedChartSource(AChartSeries.Source).Percentage := (AWorkbookSeries.Chart.StackMode = csmStackedPercentage);
|
TCalculatedChartSource(AChartSeries.Source).Percentage := (AWorkbookSeries.Chart.StackMode = csmStackedPercentage);
|
||||||
|
|
||||||
|
UpdateChartErrorBars(AWorkbookSeries, AChartSeries);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TsWorkbookChartLink.UpdatePieSeries(AWorkbookSeries: TsPieSeries;
|
procedure TsWorkbookChartLink.UpdatePieSeries(AWorkbookSeries: TsPieSeries;
|
||||||
@ -2262,6 +2340,9 @@ begin
|
|||||||
ser.Title := ser.Title + LineEnding + s;
|
ser.Title := ser.Title + LineEnding + s;
|
||||||
// ser.Legend.Format := '%0:s' + LineEnding + '%2:s';
|
// ser.Legend.Format := '%0:s' + LineEnding + '%2:s';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// Error bars
|
||||||
|
UpdateChartErrorBars(AWorkbookSeries, AChartSeries);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TsWorkbookChartLink.UpdateStockSeries(AWorkbookSeries: TsStockSeries;
|
procedure TsWorkbookChartLink.UpdateStockSeries(AWorkbookSeries: TsStockSeries;
|
||||||
|
Reference in New Issue
Block a user