fpspreadsheet: Fix visibility of chart legend and axis labels

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9058 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-11-29 12:23:09 +00:00
parent 1a1da84fc8
commit 8be0fe4703
3 changed files with 25 additions and 14 deletions

View File

@ -1654,7 +1654,6 @@ begin
FSubTitle.Font.Size := 12;
FLegend := TsChartLegend.Create(self);
FLegend.Visible := false;
FXAxis := TsChartAxis.Create(self);
FXAxis.Title.Caption := 'x axis';

View File

@ -89,11 +89,9 @@ type
AEquation: TsRegressionEquation; AIndent, AStyleID: Integer): String;
function GetChartRegressionStyleAsXML(AChart: TsChart; ASeriesIndex, AIndent, AStyleID: Integer): String;
function GetChartSeriesStyleAsXML(AChart: TsChart; ASeriesIndex, AIndent, AStyleID: integer): String;
// function GetChartTitleStyleAsXML(AChart: TsChart; AStyleIndex, AIndent: Integer): String;
function GetNumberFormatID(ANumFormat: String): String;
procedure ListAllNumberFormats(AChart: TsChart);
// procedure PrepareChartTable(AChart: TsChart; AWorksheet: TsBasicWorksheet);
protected
// Object X/styles.xml
@ -549,6 +547,9 @@ var
chartChartNode: TDOMNode;
chartElementNode: TDOMNode;
begin
// Default values
AChart.Legend.Visible := false;
nodeName := AStyleNode.NodeName;
if nodeName = 'office:automatic-styles' then
TsSpreadOpenDocReader(Reader).ReadNumFormats(AStyleNode, FNumberFormatList);
@ -2290,7 +2291,8 @@ begin
// Chart properties
chartProps := 'chart:symbol-type="none" ';
if (series is TsLineSeries) and (series.ChartType <> ctFilledRadar) then
if ((series is TsLineSeries) and (series.ChartType <> ctFilledRadar)) or
(series is TsScatterSeries) then
begin
lineser := TsLineSeries(series);
if lineser.ShowSymbols then
@ -3205,7 +3207,7 @@ begin
series := AChart.Series[ASeriesIndex];
// These are the x values of a scatter plot.
if (series is TsScatterSeries) then
if (series is TsCustomScatterSeries) then
begin
domainRangeX := GetSheetCellRangeString_ODS(
series.XRange.GetSheet1Name, series.XRange.GetSheet2Name,

View File

@ -1586,14 +1586,23 @@ end;
procedure TsWorkbookChartLink.UpdateChartAxisLabels(AWorkbookChart: TsChart);
begin
if (FChart.SeriesCount > 0) and
(AWorkbookChart.GetChartType in [ctBar, ctLine, ctArea]) then
begin
FChart.BottomAxis.Marks.Source := TChartSeries(FChart.Series[0]).Source;
if not AWorkbookChart.Series[0].LabelRange.IsEmpty then
FChart.BottomAxis.Marks.Style := smsLabel
else
FChart.BottomAxis.Marks.Style := smsXValue;
if FChart.SeriesCount = 0 then
exit;
case AWorkbookChart.GetChartType of
ctScatter, ctBubble:
begin
FChart.BottomAxis.Marks.Source := nil;
FChart.BottomAxis.Marks.Style := smsValue;
end;
ctBar, ctLine, ctArea:
begin
FChart.BottomAxis.Marks.Source := TChartSeries(FChart.Series[0]).Source;
if not AWorkbookChart.Series[0].LabelRange.IsEmpty then
FChart.BottomAxis.Marks.Style := smsLabel
else
FChart.BottomAxis.Marks.Style := smsXValue;
end;
end;
end;
@ -1665,7 +1674,6 @@ begin
ALegend.Alignment := LEG_POS[AWorkbookLegend.Position];
ALegend.UseSidebar := not AWorkbookLegend.CanOverlapPlotArea;
ALegend.Visible := AWorkbookLegend.Visible;
// ALegend.Inverted := true;
ALegend.TextFormat := tfHTML;
end;
end;
@ -1877,8 +1885,10 @@ begin
// Legend text
ser.Title := AWorkbookSeries.Regression.Title;
{
// Show fit curve in legend after series.
ser.Legend.Order := AChartseries.Legend.Order + 1;
}
// Regression equation
if AWorkbookSeries.Regression.DisplayEquation or AWorkbookSeries.Regression.DisplayRSquare then