fpspreadsheet: xlsx reader supports series data point callouts.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9180 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2024-01-27 19:08:16 +00:00
parent 78158a61fd
commit 67a83b5fae
3 changed files with 64 additions and 5 deletions

View File

@ -386,6 +386,11 @@ type
TsChartDataLabel = (cdlValue, cdlPercentage, cdlCategory, cdlSeriesName, cdlSymbol); TsChartDataLabel = (cdlValue, cdlPercentage, cdlCategory, cdlSeriesName, cdlSymbol);
TsChartDataLabels = set of TsChartDataLabel; TsChartDataLabels = set of TsChartDataLabel;
TsChartLabelPosition = (lpDefault, lpOutside, lpInside, lpCenter); TsChartLabelPosition = (lpDefault, lpOutside, lpInside, lpCenter);
TsChartLabelCalloutShape = (
lcsRectangle, lcsRoundRect, lcsEllipse,
lcsLeftArrow, lcsUpArrow, lcsRightArrow, lcsDownArrow,
lcsRectangleWedge, lcsRoundRectWedge, lcsEllipseWedge
);
TsChartDataPointStyle = class(TsChartFillElement); TsChartDataPointStyle = class(TsChartFillElement);
@ -501,6 +506,7 @@ type
FTitleAddr: TsChartCellAddr; FTitleAddr: TsChartCellAddr;
FLabelFormat: String; FLabelFormat: String;
FDataLabels: TsChartDataLabels; FDataLabels: TsChartDataLabels;
FDataLabelCalloutShape: TsChartLabelCalloutShape;
FDataPointStyles: TsChartDataPointStyleList; FDataPointStyles: TsChartDataPointStyleList;
FOrder: Integer; FOrder: Integer;
FRegression: TsChartRegression; FRegression: TsChartRegression;
@ -542,6 +548,7 @@ type
property ChartType: TsChartType read GetChartType; property ChartType: TsChartType read GetChartType;
property Count: Integer read GetCount; property Count: Integer read GetCount;
property DataLabels: TsChartDataLabels read FDataLabels write FDataLabels; property DataLabels: TsChartDataLabels read FDataLabels write FDataLabels;
property DataLabelCalloutShape: TsChartLabelCalloutShape read FDataLabelCalloutShape write FDataLabelCalloutShape;
property DataPointStyles: TsChartDatapointStyleList read FDataPointStyles; property DataPointStyles: TsChartDatapointStyleList read FDataPointStyles;
property FillColorRange: TsChartRange read FFillColorRange write FFillColorRange; property FillColorRange: TsChartRange read FFillColorRange write FFillColorRange;
property LabelBackground: TsChartFill read FLabelBackground write FLabelBackground; property LabelBackground: TsChartFill read FLabelBackground write FLabelBackground;

View File

@ -1662,7 +1662,7 @@ procedure TsSpreadOOXMLChartReader.ReadChartSeriesLabels(ANode: TDOMNode;
ASeries: TsChartSeries); ASeries: TsChartSeries);
var var
nodeName, s: String; nodeName, s: String;
child, child2, child3: TDOMNode; child1, child2, child3: TDOMNode;
begin begin
if ANode = nil then if ANode = nil then
exit; exit;
@ -1675,10 +1675,10 @@ begin
ReadChartFillAndLineProps(ANode.FirstChild, ASeries.Chart, ASeries.LabelBackground, ASeries.LabelBorder); ReadChartFillAndLineProps(ANode.FirstChild, ASeries.Chart, ASeries.LabelBackground, ASeries.LabelBorder);
'c:txPr': 'c:txPr':
begin begin
child := ANode.FindNode('a:p'); child1 := ANode.FindNode('a:p');
if Assigned(child) then if Assigned(child1) then
begin begin
child2 := child.FirstChild; child2 := child1.FirstChild;
while Assigned(child2) do while Assigned(child2) do
begin begin
nodeName := child2.NodeName; nodeName := child2.NodeName;
@ -1715,7 +1715,50 @@ begin
'c:showLeaderLines': 'c:showLeaderLines':
; ;
'c:extLst': 'c:extLst':
; begin
child1 := ANode.FirstChild;
while Assigned(child1) do
begin
nodeName := child1.NodeName;
if nodeName = 'c:ext' then
begin
child2 := child1.FirstChild;
while Assigned(child2) do
begin
nodeName := child2.NodeName;
if nodeName = 'c15:spPr' then
begin
child3 := child2.FindNode('a:prstGeom');
if Assigned(child3) then
begin
s := GetAttrValue(child3, 'prst');
case s of
'rect': ASeries.DataLabelCalloutShape := lcsRectangle;
'roundRect': ASeries.DataLabelCalloutShape := lcsRoundRect;
'ellipse': ASeries.DataLabelCalloutShape := lcsEllipse;
'rightArrowCallout': ASeries.DataLabelCalloutShape := lcsRightArrow;
'downArrowCallout': ASeries.DataLabelCalloutShape := lcsDownArrow;
'leftArrowCallout': ASeries.DataLabelCalloutShape := lcsLeftArrow;
'upArrowCallout': ASeries.DataLabelCalloutShape := lcsUpArrow;
'wedgeRectCallout': ASeries.DataLabelCalloutShape := lcsRectangleWedge;
'wedgeRoundRectCallout': ASeries.DataLabelCalloutShape := lcsRoundRectWedge;
'wedgeEllipseCallout': ASeries.DataLabelCalloutShape := lcsEllipseWedge;
else ASeries.DataLabelCalloutShape := lcsRectangle;
{
'borderCallout1': ;
'borderCallout2': ;
'accentCallout1': ;
'accentCallout2': ;
}
end;
end;
end;
child2 := child2.NextSibling;
end;
end;
child1 := child1.NextSibling;
end;
end;
end; end;
ANode := ANode.NextSibling; ANode := ANode.NextSibling;
end; end;

View File

@ -2435,6 +2435,15 @@ begin
UpdateChartPen(AWorkbookSeries.Chart, AWorkbookSeries.LabelBorder, AChartSeries.Marks.Frame); UpdateChartPen(AWorkbookSeries.Chart, AWorkbookSeries.LabelBorder, AChartSeries.Marks.Frame);
UpdateChartBrush(AWorkbookSeries.Chart, AWorkbookSeries.LabelBackground, AChartSeries.Marks.LabelBrush); UpdateChartBrush(AWorkbookSeries.Chart, AWorkbookSeries.LabelBackground, AChartSeries.Marks.LabelBrush);
case AWorkbookSeries.DataLabelCalloutShape of
lcsRectangle: AChartSeries.Marks.Shape := clsRectangle;
lcsRoundRect: AChartSeries.Marks.Shape := clsRoundRect;
lcsEllipse: AChartSeries.Marks.Shape := clsEllipse;
lcsRectangleWedge: AChartSeries.Marks.Shape := clsRectangle; // replacement
lcsRoundRectWedge: AChartSeries.Marks.Shape := clsRoundRect; // replacement
lcsEllipseWedge: AChartSeries.Marks.Shape := clsEllipse; // replacement
else AChartSeries.Marks.Shape := clsRectangle; // replacement
end;
end; end;
procedure TsWorkbookChartLink.UpdateChartSeriesRegression(AWorkbookSeries: TsChartSeries; procedure TsWorkbookChartLink.UpdateChartSeriesRegression(AWorkbookSeries: TsChartSeries;