fpspreadsheet: Adjust chart link to new percentage-sized bubble series radii. No longer ignore font of series labels.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9062 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-11-30 23:20:34 +00:00
parent 1d1a337eed
commit fb4abdab4d
4 changed files with 48 additions and 23 deletions

View File

@ -24,7 +24,7 @@ object Form1: TForm1
AutoAdvance = aaDown AutoAdvance = aaDown
DefaultColWidth = 64 DefaultColWidth = 64
DefaultRowHeight = 22 DefaultRowHeight = 22
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll] Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goRowSizing, goColSizing, goEditing, goSmoothScroll]
TabOrder = 0 TabOrder = 0
end end
object Splitter1: TSplitter object Splitter1: TSplitter

View File

@ -31,7 +31,6 @@ type
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
private private
sChartLink: TsWorkbookChartLink; sChartLink: TsWorkbookChartLink;
FFileName: String;
procedure LoadFile(AFileName: String); procedure LoadFile(AFileName: String);
public public
@ -91,6 +90,7 @@ end;
procedure TForm1.LoadFile(AFileName: String); procedure TForm1.LoadFile(AFileName: String);
var var
fn: String; fn: String;
i: Integer;
begin begin
fn := ExpandFileName(AFileName); fn := ExpandFileName(AFileName);
if not FileExists(fn) then if not FileExists(fn) then
@ -103,6 +103,9 @@ begin
if FileExists(fn) then if FileExists(fn) then
sWorkbookSource1.Filename := fn; sWorkbookSource1.Filename := fn;
for i := 1 to sWorksheetGrid1.Worksheet.GetLastRowIndex+1 do
sWorksheetGrid1.AutoRowHeight(1);
sChartLink := TsWorkbookChartLink.Create(self); sChartLink := TsWorkbookChartLink.Create(self);
sChartLink.Chart := Chart1; sChartLink.Chart := Chart1;
sChartLink.WorkbookSource := sWorkbookSource1; sChartLink.WorkbookSource := sWorkbookSource1;

View File

@ -1320,7 +1320,7 @@ begin
end; end;
s := GetAttrValue(AStyleNode, 'chart:data-label-number'); s := GetAttrValue(AStyleNode, 'chart:data-label-number');
if s <> '' then if (s <> '') and (s <> 'none') then
Include(datalabels, cdlValue); Include(datalabels, cdlValue);
s := GetAttrValue(AStyleNode, 'chart:data-label-number="percentage"'); s := GetAttrValue(AStyleNode, 'chart:data-label-number="percentage"');
if s <> '' then if s <> '' then

View File

@ -458,7 +458,7 @@ begin
begin begin
if FRanges[rngX, i] <> nil then if FRanges[rngX, i] <> nil then
begin begin
GetXYItem(rngX, i, AIndex, value, dummyString); GetXYItem(rngX, i, AIndex, value, tmpLabel);
FCurItem.SetX(i, value); FCurItem.SetX(i, value);
end else end else
if FCyclicX then if FCyclicX then
@ -467,22 +467,7 @@ begin
value := AIndex; value := AIndex;
FCurItem.SetX(i, value); FCurItem.SetX(i, value);
end; end;
(*
if FRanges[rngX] <> nil then
begin
for i := 0 to XCount-1 do
begin
GetXYItem(rngX, i, AIndex, value, dummyString);
FCurItem.SetX(i, value);
end;
end else
begin
if FCyclicX then
FCurItem.X := AIndex / FPointsNumber * TWO_PI
else
FCurItem.X := AIndex;
end;
*)
for i := 0 to YCount-1 do for i := 0 to YCount-1 do
begin begin
GetXYItem(rngY, i, AIndex, value, dummyString); GetXYItem(rngY, i, AIndex, value, dummyString);
@ -544,7 +529,7 @@ begin
end; end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
Helper method the prepare the information required for the series data point. Helper method to prepare the information required for the series data point.
@param ARangeIndex Identifies whether the method retrieves the x or y @param ARangeIndex Identifies whether the method retrieves the x or y
coordinate, or the label text coordinate, or the label text
@ -930,11 +915,14 @@ end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
Inherited ChartSource method telling the series how many y values are used. Inherited ChartSource method telling the series how many y values are used.
Currently we support only single valued data (YCount = 1, by default).
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
procedure TsWorkbookChartSource.SetYCount(AValue: Cardinal); procedure TsWorkbookChartSource.SetYCount(AValue: Cardinal);
begin begin
{$IF LCL_FullVersion >= 3090900}
inherited SetYCount(AValue);
{$ELSE}
FYCount := AValue; FYCount := AValue;
{$ENDIF}
SetLength(FCurItem.YList, YCount-1); SetLength(FCurItem.YList, YCount-1);
end; end;
@ -1036,7 +1024,7 @@ begin
ctBubble: ctBubble:
begin begin
Result := TBubbleSeries.Create(FChart); Result := TBubbleSeries.Create(FChart);
src.SetYRange(1, TsBubbleSeries(ASeries).BubbleRange); src.SetYRange(1, TsBubbleSeries(ASeries).BubbleRange); // The radius is at YIndex 1
end; end;
ctPie: ctPie:
Result := TPieSeries.Create(FChart); Result := TPieSeries.Create(FChart);
@ -1473,6 +1461,10 @@ procedure TsWorkbookChartlink.UpdateBubbleSeries(AWorkbookSeries: TsBubbleSeries
begin begin
UpdateChartBrush(AWorkbookSeries.Chart, AWorkbookSeries.Fill, AChartSeries.BubbleBrush); UpdateChartBrush(AWorkbookSeries.Chart, AWorkbookSeries.Fill, AChartSeries.BubbleBrush);
UpdateChartPen(AWorkbookSeries.Chart, AWorkbookSeries.Line, AChartSeries.BubblePen); UpdateChartPen(AWorkbookSeries.Chart, AWorkbookSeries.Line, AChartSeries.BubblePen);
{$IF LCL_FullVersion >= 3090900}
AChartSeries.BubbleRadiusUnits := bruPercentage;
AChartSeries.ParentChart.ExpandPercentage := 10;
{$IFEND}
end; end;
procedure TsWorkbookChartLink.UpdateChart; procedure TsWorkbookChartLink.UpdateChart;
@ -1488,6 +1480,7 @@ begin
exit; exit;
end; end;
FChart.Proportional := false; FChart.Proportional := false;
FChart.ExpandPercentage := 0;
ch := GetWorkbookChart; ch := GetWorkbookChart;
UpdateChartBackground(ch); UpdateChartBackground(ch);
@ -1716,6 +1709,35 @@ procedure TsWorkbookChartLink.UpdateChartSeriesMarks(AWorkbookSeries: TsChartSer
begin begin
ConstructSeriesMarks(AWorkbookSeries, AChartSeries); ConstructSeriesMarks(AWorkbookSeries, AChartSeries);
AChartSeries.Marks.LinkPen.Visible := false; AChartSeries.Marks.LinkPen.Visible := false;
AChartSeries.Marks.YIndex := -1;
AChartSeries.Marks.Distance := 20;
AChartSeries.Marks.Attachment := maDefault;
Convert_sFont_to_Font(AWorkbookSeries.LabelFont, AChartSeries.Marks.LabelFont);
if (AChartSeries is TBubbleSeries) then
case AWorkbookSeries.LabelPosition of
lpDefault, lpOutside:
begin
TBubbleSeries(AChartSeries).MarkPositions := lmpPositive;
TBubbleSeries(AChartSeries).Marks.YIndex := 1;
TBubbleSeries(AChartSeries).Marks.Distance := 5;
end;
lpInside:
begin
TBubbleSeries(AChartSeries).MarkPositions := lmpInside;
TBubbleSeries(AChartSeries).Marks.YIndex := 1;
TBubbleSeries(AChartSeries).Marks.Distance := 5;
end;
lpCenter:
begin
TBubbleSeries(AChartSeries).MarkPositions := lmpInside;
TBubbleSeries(AChartSeries).Marks.YIndex := 0; // 0 --> at data point
TBubbleSeries(AChartSeries).Marks.Distance := 0;
TBubbleSeries(AChartSeries).Marks.Attachment := maCenter;
end;
end
else
if (AChartSeries is TPieSeries) then if (AChartSeries is TPieSeries) then
case AWorkbookSeries.LabelPosition of case AWorkbookSeries.LabelPosition of
lpInside: lpInside: