fpspreadsheet: xlsx chart writer supports manual axis scaling.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9206 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
33974c6cb0
commit
a19317f379
@ -54,10 +54,12 @@ begin
|
|||||||
ch.XAxis.Title.Caption := 'Distance from Sun (relative to Earth)';
|
ch.XAxis.Title.Caption := 'Distance from Sun (relative to Earth)';
|
||||||
ch.XAxis.MinorGridLines.Style := clsNoLine;
|
ch.XAxis.MinorGridLines.Style := clsNoLine;
|
||||||
ch.XAxis.Logarithmic := true;
|
ch.XAxis.Logarithmic := true;
|
||||||
|
ch.XAxis.Max := 100;
|
||||||
ch.YAxis.Title.Caption := 'Orbital period (relative to Earth)';
|
ch.YAxis.Title.Caption := 'Orbital period (relative to Earth)';
|
||||||
ch.YAxis.AxisLine.Color := scSilver;
|
ch.YAxis.AxisLine.Color := scSilver;
|
||||||
ch.YAxis.MinorGridLines.Style := clsNoLine;
|
ch.YAxis.MinorGridLines.Style := clsNoLine;
|
||||||
ch.YAxis.Logarithmic := true;
|
ch.YAxis.Logarithmic := true;
|
||||||
|
ch.YAxis.Max := 1000;
|
||||||
|
|
||||||
// Add data as bubble series
|
// Add data as bubble series
|
||||||
ser := TsBubbleSeries.Create(ch);
|
ser := TsBubbleSeries.Create(ch);
|
||||||
|
@ -100,12 +100,14 @@ begin
|
|||||||
ch.Legend.Border.Style := clsNoLine;
|
ch.Legend.Border.Style := clsNoLine;
|
||||||
// Set up logarithmic axes if needed.
|
// Set up logarithmic axes if needed.
|
||||||
case mode of
|
case mode of
|
||||||
0: ;
|
0: begin
|
||||||
|
ch.XAxis.MajorInterval := 20;
|
||||||
|
ch.XAxis.MinorInterval := 5;
|
||||||
|
end;
|
||||||
1: ch.YAxis.Logarithmic := true;
|
1: ch.YAxis.Logarithmic := true;
|
||||||
2: begin
|
2: begin
|
||||||
ch.XAxis.Logarithmic := true;
|
ch.XAxis.Logarithmic := true;
|
||||||
ch.XAxis.Max := 100;
|
ch.XAxis.Max := 100;
|
||||||
ch.XAxis.AutomaticMax := false;
|
|
||||||
ch.YAxis.Logarithmic := true;
|
ch.YAxis.Logarithmic := true;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -114,7 +116,7 @@ begin
|
|||||||
ser := TsScatterSeries.Create(ch);
|
ser := TsScatterSeries.Create(ch);
|
||||||
|
|
||||||
// Series properties
|
// Series properties
|
||||||
ser.SetTitleAddr(0, 0);
|
ser.SetTitleAddr(0, 0); // A1
|
||||||
ser.SetXRange(3, 0, 10, 0); // A4:A11
|
ser.SetXRange(3, 0, 10, 0); // A4:A11
|
||||||
ser.SetYRange(3, 1, 10, 1); // B4:B11
|
ser.SetYRange(3, 1, 10, 1); // B4:B11
|
||||||
ser.ShowLines := true;
|
ser.ShowLines := true;
|
||||||
|
@ -321,6 +321,11 @@ type
|
|||||||
FPositionValue: Double;
|
FPositionValue: Double;
|
||||||
FShowLabels: Boolean;
|
FShowLabels: Boolean;
|
||||||
FDateTime: Boolean;
|
FDateTime: Boolean;
|
||||||
|
procedure SetMax(AValue: Double);
|
||||||
|
procedure SetMin(AValue: Double);
|
||||||
|
procedure SetMinorCount(AValue: Integer);
|
||||||
|
procedure SetMajorInterval(AValue: Double);
|
||||||
|
procedure SetMinorInterval(AValue: Double);
|
||||||
public
|
public
|
||||||
constructor Create(AChart: TsChart);
|
constructor Create(AChart: TsChart);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -348,13 +353,13 @@ type
|
|||||||
property Logarithmic: Boolean read FLogarithmic write FLogarithmic;
|
property Logarithmic: Boolean read FLogarithmic write FLogarithmic;
|
||||||
property LogBase: Double read FLogBase write FLogBase;
|
property LogBase: Double read FLogBase write FLogBase;
|
||||||
property MajorGridLines: TsChartLine read FMajorGridLines write FMajorGridLines;
|
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 MajorTicks: TsChartAxisTicks read FMajorTicks write FMajorTicks;
|
||||||
property Max: Double read FMax write FMax;
|
property Max: Double read FMax write SetMax;
|
||||||
property Min: Double read FMin write FMin;
|
property Min: Double read FMin write SetMin;
|
||||||
property MinorGridLines: TsChartLine read FMinorGridLines write FMinorGridLines;
|
property MinorGridLines: TsChartLine read FMinorGridLines write FMinorGridLines;
|
||||||
property MinorCount: Integer read FMinorCount write FMinorCount;
|
property MinorCount: Integer read FMinorCount write SetMinorCount;
|
||||||
property MinorInterval: Double read FMinorInterval write FMinorInterval;
|
property MinorInterval: Double read FMinorInterval write SetMinorInterval;
|
||||||
property MinorTicks: TsChartAxisTicks read FMinorTicks write FMinorTicks;
|
property MinorTicks: TsChartAxisTicks read FMinorTicks write FMinorTicks;
|
||||||
property Position: TsChartAxisPosition read FPosition write FPosition;
|
property Position: TsChartAxisPosition read FPosition write FPosition;
|
||||||
property PositionValue: Double read FPositionValue write FPositionValue;
|
property PositionValue: Double read FPositionValue write FPositionValue;
|
||||||
@ -869,7 +874,7 @@ type
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
fpSpreadsheet;
|
Math, fpSpreadsheet;
|
||||||
|
|
||||||
{ TsChartLine }
|
{ TsChartLine }
|
||||||
|
|
||||||
@ -1663,6 +1668,7 @@ begin
|
|||||||
FAutomaticMin := true;
|
FAutomaticMin := true;
|
||||||
FAutomaticMax := true;
|
FAutomaticMax := true;
|
||||||
FAutomaticMajorInterval := true;
|
FAutomaticMajorInterval := true;
|
||||||
|
FAutomaticMinorInterval := true;
|
||||||
FAutomaticMinorSteps := true;
|
FAutomaticMinorSteps := true;
|
||||||
|
|
||||||
FCategoryRange := TsChartRange.Create(AChart);
|
FCategoryRange := TsChartRange.Create(AChart);
|
||||||
@ -1801,6 +1807,63 @@ begin
|
|||||||
FCategoryRange.Col2 := ACol2;
|
FCategoryRange.Col2 := ACol2;
|
||||||
end;
|
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 }
|
{ TsChartLegend }
|
||||||
|
|
||||||
constructor TsChartLegend.Create(AChart: TsChart);
|
constructor TsChartLegend.Create(AChart: TsChart);
|
||||||
|
@ -3415,6 +3415,7 @@ begin
|
|||||||
AppendToStream(AStream, Format(
|
AppendToStream(AStream, Format(
|
||||||
indent + '<c:barChart>' + LE +
|
indent + '<c:barChart>' + LE +
|
||||||
indent + ' <c:barDir val="col"/>' + LE +
|
indent + ' <c:barDir val="col"/>' + LE +
|
||||||
|
indent + ' <c:varyColors val="0"/>' + LE +
|
||||||
indent + ' <c:grouping val="%s"/>' + LE,
|
indent + ' <c:grouping val="%s"/>' + LE,
|
||||||
[ GROUPING[chart.StackMode] ]
|
[ GROUPING[chart.StackMode] ]
|
||||||
));
|
));
|
||||||
@ -3461,7 +3462,8 @@ begin
|
|||||||
chart := ASeries.Chart;
|
chart := ASeries.Chart;
|
||||||
|
|
||||||
AppendToStream(AStream,
|
AppendToStream(AStream,
|
||||||
indent + '<c:bubbleChart>' + LE
|
indent + '<c:bubbleChart>' + LE +
|
||||||
|
indent + ' <c:varyColors val="0"/>' + LE
|
||||||
);
|
);
|
||||||
|
|
||||||
WriteChartSeriesNode(AStream, AIndent + 2, ASeries, ASeriesIndex);
|
WriteChartSeriesNode(AStream, AIndent + 2, ASeries, ASeriesIndex);
|
||||||
@ -3588,19 +3590,41 @@ procedure TsSpreadOOXMLChartWriter.WriteChartAxisScaling(AStream: TStream;
|
|||||||
AIndent: Integer; Axis: TsChartAxis);
|
AIndent: Integer; Axis: TsChartAxis);
|
||||||
var
|
var
|
||||||
indent: String;
|
indent: String;
|
||||||
|
intv: Double;
|
||||||
logStr: String = '';
|
logStr: String = '';
|
||||||
|
maxStr: String = '';
|
||||||
|
minStr: String = '';
|
||||||
begin
|
begin
|
||||||
indent := DupeString(' ', AIndent);
|
indent := DupeString(' ', AIndent);
|
||||||
|
|
||||||
|
if not Axis.AutomaticMax then
|
||||||
|
maxStr := indent + Format(' <c:max val="%g"/>', [Axis.Max], FPointSeparatorSettings) + LE;
|
||||||
|
|
||||||
|
if not Axis.AutomaticMin then
|
||||||
|
minStr := indent + Format(' <c:min val="&g"/>', [Axis.Min], FPointSeparatorSettings) + LE;
|
||||||
|
|
||||||
if Axis.Logarithmic then
|
if Axis.Logarithmic then
|
||||||
logStr := indent + Format(' <c:logBase val="%g"/>', [Axis.LogBase], FPointSeparatorSettings) + LE;
|
logStr := indent + Format(' <c:logBase val="%g"/>', [Axis.LogBase], FPointSeparatorSettings) + LE;
|
||||||
|
|
||||||
AppendToStream(AStream,
|
AppendToStream(AStream,
|
||||||
indent + '<c:scaling>' + LE +
|
indent + '<c:scaling>' + LE +
|
||||||
|
maxStr +
|
||||||
|
minStr +
|
||||||
logStr +
|
logStr +
|
||||||
indent + ' <c:orientation val="minMax"/>' + LE +
|
indent + ' <c:orientation val="minMax"/>' + LE +
|
||||||
indent + '</c:scaling>' + LE
|
indent + '</c:scaling>' + LE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// The following nodes are outside the <c:scaling node> !
|
||||||
|
if not Axis.AutomaticMajorInterval then
|
||||||
|
AppendToStream(AStream, Format(
|
||||||
|
indent + '<c:majorUnit val="%g"/>', [Axis.MajorInterval], fPointSeparatorSettings) + LE
|
||||||
|
);
|
||||||
|
|
||||||
|
if not Axis.AutomaticMinorInterval then
|
||||||
|
AppendToStream(AStream, Format(
|
||||||
|
indent + '<c:minorUnit val="%g"/>', [Axis.MinorInterval], FPointSeparatorSettings) + LE
|
||||||
|
);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TsSpreadOOXMLChartWriter.WriteChartAxisTitle(AStream: TStream;
|
procedure TsSpreadOOXMLChartWriter.WriteChartAxisTitle(AStream: TStream;
|
||||||
@ -3873,6 +3897,7 @@ begin
|
|||||||
|
|
||||||
AppendToStream(AStream,
|
AppendToStream(AStream,
|
||||||
indent + '<c:scatterChart>' + LE +
|
indent + '<c:scatterChart>' + LE +
|
||||||
|
indent + ' <c:varyColors val="0"/>' + LE +
|
||||||
indent + ' <c:scatterStyle val="lineMarker"/>' + LE
|
indent + ' <c:scatterStyle val="lineMarker"/>' + LE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user