fpspreadsheet: Implement axis position for xlsx writer. Fix its transfer to TAChart.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9261 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
8d065c3c40
commit
67802d571d
@ -372,6 +372,7 @@ type
|
|||||||
property MinorCount: Integer read FMinorCount write SetMinorCount;
|
property MinorCount: Integer read FMinorCount write SetMinorCount;
|
||||||
property MinorInterval: Double read FMinorInterval write SetMinorInterval;
|
property MinorInterval: Double read FMinorInterval write SetMinorInterval;
|
||||||
property MinorTicks: TsChartAxisTicks read FMinorTicks write FMinorTicks;
|
property MinorTicks: TsChartAxisTicks read FMinorTicks write FMinorTicks;
|
||||||
|
// Position and PositionValue define where the axis is crossed by the other axis
|
||||||
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;
|
||||||
property ShowLabels: Boolean read FShowLabels write FShowLabels;
|
property ShowLabels: Boolean read FShowLabels write FShowLabels;
|
||||||
|
@ -427,6 +427,20 @@ begin
|
|||||||
x := DEFAULT_TEXT_DIR[AChart.RotatedAxes, AChartAxis.Alignment]; // not sure, but maybe 1000 means: default
|
x := DEFAULT_TEXT_DIR[AChart.RotatedAxes, AChartAxis.Alignment]; // not sure, but maybe 1000 means: default
|
||||||
AChartAxis.LabelRotation := x;
|
AChartAxis.LabelRotation := x;
|
||||||
end;
|
end;
|
||||||
|
'c:crossAx':
|
||||||
|
;
|
||||||
|
'c:crosses':
|
||||||
|
case s of
|
||||||
|
'min': AChartAxis.Position := capStart;
|
||||||
|
'max': AChartAxis.Position := capEnd;
|
||||||
|
'autoZero': AChartAxis.Position := capStart;
|
||||||
|
end;
|
||||||
|
'c:crossesAt':
|
||||||
|
if TryStrToFloat(s, x, FPointSeparatorSettings) then
|
||||||
|
begin
|
||||||
|
AChartAxis.Position := capValue;
|
||||||
|
AChartAxis.PositionValue := x;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
ANode := ANode.NextSibling;
|
ANode := ANode.NextSibling;
|
||||||
end;
|
end;
|
||||||
@ -3768,21 +3782,17 @@ var
|
|||||||
indent: String;
|
indent: String;
|
||||||
chart: TsChart;
|
chart: TsChart;
|
||||||
axID: DWord;
|
axID: DWord;
|
||||||
rotAxID: DWord;
|
crosses: String;
|
||||||
crosses: String = 'autoZero';
|
|
||||||
delete: Integer = 0;
|
delete: Integer = 0;
|
||||||
axAlign: TsChartAxisAlignment;
|
axAlign: TsChartAxisAlignment;
|
||||||
|
rotAxID: DWord;
|
||||||
|
rotAxis: TsChartAxis;
|
||||||
begin
|
begin
|
||||||
indent := DupeString(' ', AIndent);
|
indent := DupeString(' ', AIndent);
|
||||||
chart := Axis.Chart;
|
chart := Axis.Chart;
|
||||||
|
|
||||||
axID := FAxisID[Axis.Alignment];
|
axID := FAxisID[Axis.Alignment];
|
||||||
rotAxID := FAxisID[Axis.GetRotatedAxis.Alignment];
|
rotAxID := FAxisID[Axis.GetRotatedAxis.Alignment];
|
||||||
if (Axis = chart.Y2Axis) then
|
|
||||||
crosses := 'max'
|
|
||||||
else
|
|
||||||
if (Axis = chart.YAxis) and (chart.GetChartType in [ctBar]) then
|
|
||||||
crosses := 'min';
|
|
||||||
if Axis = chart.X2Axis then
|
if Axis = chart.X2Axis then
|
||||||
delete := 1;
|
delete := 1;
|
||||||
|
|
||||||
@ -3818,20 +3828,33 @@ begin
|
|||||||
if Axis.ShowLabels then
|
if Axis.ShowLabels then
|
||||||
WriteChartLabels(AStream, AIndent + 2, Axis.LabelFont);
|
WriteChartLabels(AStream, AIndent + 2, Axis.LabelFont);
|
||||||
|
|
||||||
|
// Axis position
|
||||||
|
case Axis.Position of
|
||||||
|
capStart:
|
||||||
|
crosses := ' <c:crosses val="min"/>';
|
||||||
|
capEnd:
|
||||||
|
crosses := ' <c:crosses val="max"/>';
|
||||||
|
capValue:
|
||||||
|
crosses := Format(' <c:crossesAt val="%g"/>', [Axis.PositionValue], FPointSeparatorSettings);
|
||||||
|
else
|
||||||
|
raise Exception.Create('Unsupported value of Axis.Position');
|
||||||
|
// not used here: "autoZero"
|
||||||
|
end;
|
||||||
|
if crosses <> '' then crosses := indent + crosses + LE;
|
||||||
|
|
||||||
AppendToStream(AStream, Format(
|
AppendToStream(AStream, Format(
|
||||||
indent + ' <c:numFmt formatCode="General" sourceLinked="1"/>' + LE +
|
indent + ' <c:numFmt formatCode="General" sourceLinked="1"/>' + LE +
|
||||||
indent + ' <c:majorTickMark val="%s"/>' + LE +
|
indent + ' <c:majorTickMark val="%s"/>' + LE +
|
||||||
indent + ' <c:minorTickMark val="%s"/>' + LE +
|
indent + ' <c:minorTickMark val="%s"/>' + LE +
|
||||||
indent + ' <c:tickLblPos val="nextTo"/>' + LE +
|
indent + ' <c:tickLblPos val="nextTo"/>' + LE +
|
||||||
indent + ' <c:crossAx val="%d" />' + LE +
|
indent + ' <c:crossAx val="%d"/>' + LE +
|
||||||
indent + ' <c:crosses val="%s"/>' + LE +
|
crosses +
|
||||||
// indent + ' <c:auto val="1"/>' + LE +
|
// indent + ' <c:auto val="1"/>' + LE +
|
||||||
indent + '</%s>' + LE,
|
indent + '</%s>' + LE,
|
||||||
[
|
[
|
||||||
GetTickMarkStr(Axis.MajorTicks), // <c:majorTickMark>
|
GetTickMarkStr(Axis.MajorTicks), // <c:majorTickMark>
|
||||||
GetTickMarkStr(Axis.MinorTicks), // <c:minorTickMark>
|
GetTickMarkStr(Axis.MinorTicks), // <c:minorTickMark>
|
||||||
rotAxID, // <c:crossAx>
|
rotAxID, // <c:crossAx>
|
||||||
crosses, // <c:crosses>
|
|
||||||
ANodeName // </c:catAx> or </c:valAx>
|
ANodeName // </c:catAx> or </c:valAx>
|
||||||
]
|
]
|
||||||
));
|
));
|
||||||
|
@ -2228,6 +2228,29 @@ begin
|
|||||||
axis.Intervals.MinLength := 20;
|
axis.Intervals.MinLength := 20;
|
||||||
axis.Intervals.Tolerance := 0;
|
axis.Intervals.Tolerance := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// Axis position
|
||||||
|
case AWorkbookAxis.Position of
|
||||||
|
capStart:
|
||||||
|
begin
|
||||||
|
axis.Position := 0;
|
||||||
|
axis.PositionUnits := cuPercent;
|
||||||
|
end;
|
||||||
|
capEnd:
|
||||||
|
begin
|
||||||
|
axis.Position := 100;
|
||||||
|
axis.PositionUnits := cuPercent;
|
||||||
|
// To do: Move TAChart axis labels and title to the other side
|
||||||
|
end;
|
||||||
|
capValue:
|
||||||
|
begin
|
||||||
|
if AWorkbookAxis.GetRotatedAxis.Logarithmic then
|
||||||
|
axis.Position := log10(AWorkbookAxis.PositionValue)
|
||||||
|
else
|
||||||
|
axis.Position := AWorkbookAxis.PositionValue;
|
||||||
|
axis.PositionUnits := cuGraph; // To do: cuAxis not yet implemented in TAChart...
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TsWorkbookChartLink.UpdateChartAxisLabels(AWorkbookChart: TsChart);
|
procedure TsWorkbookChartLink.UpdateChartAxisLabels(AWorkbookChart: TsChart);
|
||||||
|
Loading…
Reference in New Issue
Block a user