diff --git a/components/fpspreadsheet/examples/other/chart/bubblechart_write_demo.lpr b/components/fpspreadsheet/examples/other/chart/bubblechart_write_demo.lpr index b6a8ac791..efff190e4 100644 --- a/components/fpspreadsheet/examples/other/chart/bubblechart_write_demo.lpr +++ b/components/fpspreadsheet/examples/other/chart/bubblechart_write_demo.lpr @@ -54,10 +54,12 @@ begin ch.XAxis.Title.Caption := 'Distance from Sun (relative to Earth)'; ch.XAxis.MinorGridLines.Style := clsNoLine; ch.XAxis.Logarithmic := true; + ch.XAxis.Max := 100; ch.YAxis.Title.Caption := 'Orbital period (relative to Earth)'; ch.YAxis.AxisLine.Color := scSilver; ch.YAxis.MinorGridLines.Style := clsNoLine; ch.YAxis.Logarithmic := true; + ch.YAxis.Max := 1000; // Add data as bubble series ser := TsBubbleSeries.Create(ch); diff --git a/components/fpspreadsheet/examples/other/chart/scatter_write_demo.lpr b/components/fpspreadsheet/examples/other/chart/scatter_write_demo.lpr index 418b31871..b0910ceab 100644 --- a/components/fpspreadsheet/examples/other/chart/scatter_write_demo.lpr +++ b/components/fpspreadsheet/examples/other/chart/scatter_write_demo.lpr @@ -100,12 +100,14 @@ begin ch.Legend.Border.Style := clsNoLine; // Set up logarithmic axes if needed. case mode of - 0: ; + 0: begin + ch.XAxis.MajorInterval := 20; + ch.XAxis.MinorInterval := 5; + end; 1: ch.YAxis.Logarithmic := true; 2: begin ch.XAxis.Logarithmic := true; ch.XAxis.Max := 100; - ch.XAxis.AutomaticMax := false; ch.YAxis.Logarithmic := true; end; end; @@ -114,7 +116,7 @@ begin ser := TsScatterSeries.Create(ch); // Series properties - ser.SetTitleAddr(0, 0); + ser.SetTitleAddr(0, 0); // A1 ser.SetXRange(3, 0, 10, 0); // A4:A11 ser.SetYRange(3, 1, 10, 1); // B4:B11 ser.ShowLines := true; diff --git a/components/fpspreadsheet/source/common/fpschart.pas b/components/fpspreadsheet/source/common/fpschart.pas index 6a6f25f58..93da9fd5b 100644 --- a/components/fpspreadsheet/source/common/fpschart.pas +++ b/components/fpspreadsheet/source/common/fpschart.pas @@ -321,6 +321,11 @@ type FPositionValue: Double; FShowLabels: Boolean; FDateTime: Boolean; + procedure SetMax(AValue: Double); + procedure SetMin(AValue: Double); + procedure SetMinorCount(AValue: Integer); + procedure SetMajorInterval(AValue: Double); + procedure SetMinorInterval(AValue: Double); public constructor Create(AChart: TsChart); destructor Destroy; override; @@ -348,13 +353,13 @@ type property Logarithmic: Boolean read FLogarithmic write FLogarithmic; property LogBase: Double read FLogBase write FLogBase; property MajorGridLines: TsChartLine read FMajorGridLines write FMajorGridLines; - property MajorInterval: Double read FMajorInterval write FMajorInterval; + property MajorInterval: Double read FMajorInterval write SetMajorInterval; property MajorTicks: TsChartAxisTicks read FMajorTicks write FMajorTicks; - property Max: Double read FMax write FMax; - property Min: Double read FMin write FMin; + property Max: Double read FMax write SetMax; + property Min: Double read FMin write SetMin; property MinorGridLines: TsChartLine read FMinorGridLines write FMinorGridLines; - property MinorCount: Integer read FMinorCount write FMinorCount; - property MinorInterval: Double read FMinorInterval write FMinorInterval; + property MinorCount: Integer read FMinorCount write SetMinorCount; + property MinorInterval: Double read FMinorInterval write SetMinorInterval; property MinorTicks: TsChartAxisTicks read FMinorTicks write FMinorTicks; property Position: TsChartAxisPosition read FPosition write FPosition; property PositionValue: Double read FPositionValue write FPositionValue; @@ -869,7 +874,7 @@ type implementation uses - fpSpreadsheet; + Math, fpSpreadsheet; { TsChartLine } @@ -1663,6 +1668,7 @@ begin FAutomaticMin := true; FAutomaticMax := true; FAutomaticMajorInterval := true; + FAutomaticMinorInterval := true; FAutomaticMinorSteps := true; FCategoryRange := TsChartRange.Create(AChart); @@ -1801,6 +1807,63 @@ begin FCategoryRange.Col2 := ACol2; end; +procedure TsChartAxis.SetMajorInterval(AValue: Double); +begin + if IsNaN(AValue) or (AValue <= 0) then + FAutomaticMajorInterval := true + else + begin + FAutomaticMajorInterval := false; + FMajorInterval := AValue; + end; +end; + +procedure TsChartAxis.SetMax(AValue: Double); +begin + if IsNaN(AValue) then + FAutomaticMax := true + else + begin + FAutomaticMax := false; + FMax := AValue; + end; +end; + +procedure TsChartAxis.SetMin(AValue: Double); +begin + if IsNaN(AValue) then + FAutomaticMin := true + else + begin + FAutomaticMin := false; + FMin := AValue; + end; +end; + +procedure TsChartAxis.SetMinorCount(AValue: Integer); +begin + if IsNaN(AValue) or (AValue < 0) then + FAutomaticMinorSteps := true + else + begin + FAutomaticMinorSteps := false; + FMinorCount := AValue; + end; +end; + + +procedure TsChartAxis.SetMinorInterval(AValue: Double); +begin + if IsNaN(AValue) or (AValue < 0) then + FAutomaticMinorInterval := true + else + begin + FAutomaticMinorInterval := false; + FMinorInterval := AValue; + end; +end; + + { TsChartLegend } constructor TsChartLegend.Create(AChart: TsChart); diff --git a/components/fpspreadsheet/source/common/xlsxooxmlchart.pas b/components/fpspreadsheet/source/common/xlsxooxmlchart.pas index 9220dde7e..217d969d8 100644 --- a/components/fpspreadsheet/source/common/xlsxooxmlchart.pas +++ b/components/fpspreadsheet/source/common/xlsxooxmlchart.pas @@ -3415,6 +3415,7 @@ begin AppendToStream(AStream, Format( indent + '' + LE + indent + ' ' + LE + + indent + ' ' + LE + indent + ' ' + LE, [ GROUPING[chart.StackMode] ] )); @@ -3461,7 +3462,8 @@ begin chart := ASeries.Chart; AppendToStream(AStream, - indent + '' + LE + indent + '' + LE + + indent + ' ' + LE ); WriteChartSeriesNode(AStream, AIndent + 2, ASeries, ASeriesIndex); @@ -3588,19 +3590,41 @@ procedure TsSpreadOOXMLChartWriter.WriteChartAxisScaling(AStream: TStream; AIndent: Integer; Axis: TsChartAxis); var indent: String; + intv: Double; logStr: String = ''; + maxStr: String = ''; + minStr: String = ''; begin indent := DupeString(' ', AIndent); + if not Axis.AutomaticMax then + maxStr := indent + Format(' ', [Axis.Max], FPointSeparatorSettings) + LE; + + if not Axis.AutomaticMin then + minStr := indent + Format(' ', [Axis.Min], FPointSeparatorSettings) + LE; + if Axis.Logarithmic then logStr := indent + Format(' ', [Axis.LogBase], FPointSeparatorSettings) + LE; AppendToStream(AStream, indent + '' + LE + + maxStr + + minStr + logStr + indent + ' ' + LE + indent + '' + LE ); + + // The following nodes are outside the ! + if not Axis.AutomaticMajorInterval then + AppendToStream(AStream, Format( + indent + '', [Axis.MajorInterval], fPointSeparatorSettings) + LE + ); + + if not Axis.AutomaticMinorInterval then + AppendToStream(AStream, Format( + indent + '', [Axis.MinorInterval], FPointSeparatorSettings) + LE + ); end; procedure TsSpreadOOXMLChartWriter.WriteChartAxisTitle(AStream: TStream; @@ -3873,6 +3897,7 @@ begin AppendToStream(AStream, indent + '' + LE + + indent + ' ' + LE + indent + ' ' + LE );