diff --git a/components/fpspreadsheet/source/common/fpschart.pas b/components/fpspreadsheet/source/common/fpschart.pas index 51b14c74e..80dce6b26 100644 --- a/components/fpspreadsheet/source/common/fpschart.pas +++ b/components/fpspreadsheet/source/common/fpschart.pas @@ -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'; diff --git a/components/fpspreadsheet/source/common/fpsopendocumentchart.pas b/components/fpspreadsheet/source/common/fpsopendocumentchart.pas index 962d4c81b..02a0df967 100644 --- a/components/fpspreadsheet/source/common/fpsopendocumentchart.pas +++ b/components/fpspreadsheet/source/common/fpsopendocumentchart.pas @@ -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, diff --git a/components/fpspreadsheet/source/visual/fpspreadsheetchart.pas b/components/fpspreadsheet/source/visual/fpspreadsheetchart.pas index e5e19708f..5be169785 100644 --- a/components/fpspreadsheet/source/visual/fpspreadsheetchart.pas +++ b/components/fpspreadsheet/source/visual/fpspreadsheetchart.pas @@ -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