You've already forked lazarus-ccr
fpspreadsheet: Improved handling of rotated axis titles for horizontal bar charts
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8987 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -41,10 +41,6 @@ begin
|
|||||||
TsLineSeries(ser).ShowSymbols := true;
|
TsLineSeries(ser).ShowSymbols := true;
|
||||||
TsLineSeries(ser).Symbol := cssCircle;
|
TsLineSeries(ser).Symbol := cssCircle;
|
||||||
end;
|
end;
|
||||||
if (ser is TsBarSeries) then
|
|
||||||
begin
|
|
||||||
TsBarSeries(ser).Kind := bskBars;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Add second series
|
// Add second series
|
||||||
ser := SERIES_CLASS.Create(ch);
|
ser := SERIES_CLASS.Create(ch);
|
||||||
@ -67,6 +63,7 @@ begin
|
|||||||
ch.Background.Style := fsSolidFill;
|
ch.Background.Style := fsSolidFill;
|
||||||
ch.Border.Style := clsSolid;
|
ch.Border.Style := clsSolid;
|
||||||
ch.PlotArea.Background.Style := fsSolidFill;
|
ch.PlotArea.Background.Style := fsSolidFill;
|
||||||
|
ch.RotatedAxes := true;
|
||||||
|
|
||||||
ch.XAxis.ShowLabels := true;
|
ch.XAxis.ShowLabels := true;
|
||||||
ch.XAxis.LabelFont.Size := 8;
|
ch.XAxis.LabelFont.Size := 8;
|
||||||
|
@ -230,14 +230,9 @@ type
|
|||||||
end;
|
end;
|
||||||
TsChartSeriesClass = class of TsChartSeries;
|
TsChartSeriesClass = class of TsChartSeries;
|
||||||
|
|
||||||
TsBarSeriesKind = (bskColumns, bskBars);
|
|
||||||
|
|
||||||
TsBarSeries = class(TsChartSeries)
|
TsBarSeries = class(TsChartSeries)
|
||||||
private
|
|
||||||
FKind: TsBarSeriesKind;
|
|
||||||
public
|
public
|
||||||
constructor Create(AChart: TsChart); override;
|
constructor Create(AChart: TsChart); override;
|
||||||
property Kind: TsBarSeriesKind read FKind write FKind;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TsChartSeriesSymbol = (
|
TsChartSeriesSymbol = (
|
||||||
@ -288,6 +283,8 @@ type
|
|||||||
FYAxis: TsChartAxis;
|
FYAxis: TsChartAxis;
|
||||||
FY2Axis: TsChartAxis;
|
FY2Axis: TsChartAxis;
|
||||||
|
|
||||||
|
FRotatedAxes: Boolean; // For bar series: vertical columns <--> horizontal bars
|
||||||
|
|
||||||
FTitle: TsChartText;
|
FTitle: TsChartText;
|
||||||
FSubTitle: TsChartText;
|
FSubTitle: TsChartText;
|
||||||
FLegend: TsChartLegend;
|
FLegend: TsChartLegend;
|
||||||
@ -353,6 +350,8 @@ type
|
|||||||
property YAxis: TsChartAxis read FYAxis write FYAxis;
|
property YAxis: TsChartAxis read FYAxis write FYAxis;
|
||||||
{ Attributes of the plot's secondary y axis (right) }
|
{ Attributes of the plot's secondary y axis (right) }
|
||||||
property Y2Axis: TsChartAxis read FY2Axis write FY2Axis;
|
property Y2Axis: TsChartAxis read FY2Axis write FY2Axis;
|
||||||
|
{ x and y axes exchanged (for bar series) }
|
||||||
|
property RotatedAxes: Boolean read FRotatedAxes write FRotatedAxes;
|
||||||
|
|
||||||
property CategoryLabelRange: TsCellRange read GetCategoryLabelRange;
|
property CategoryLabelRange: TsCellRange read GetCategoryLabelRange;
|
||||||
|
|
||||||
|
@ -115,7 +115,6 @@ type
|
|||||||
Line: TsChartLineRec;
|
Line: TsChartLineRec;
|
||||||
Fill: TsChartFillRec;
|
Fill: TsChartFillRec;
|
||||||
Border: TsChartFillRec;
|
Border: TsChartFillRec;
|
||||||
BarSeriesKind: TsBarSeriesKind;
|
|
||||||
procedure FromChart(AChart: TsChart; AElement: TsChartStyleElement; AIndex: Integer);
|
procedure FromChart(AChart: TsChart; AElement: TsChartStyleElement; AIndex: Integer);
|
||||||
procedure ToChart(AChart: TsChart; AElement: TsChartStyleElement; AIndex: Integer);
|
procedure ToChart(AChart: TsChart; AElement: TsChartStyleElement; AIndex: Integer);
|
||||||
class operator = (A, B: TsChartSeriesRec): Boolean;
|
class operator = (A, B: TsChartSeriesRec): Boolean;
|
||||||
@ -649,10 +648,6 @@ begin
|
|||||||
Line.FromChart(AChart, AElement, AIndex);
|
Line.FromChart(AChart, AElement, AIndex);
|
||||||
Fill.FromChart(AChart, AElement, AIndex);
|
Fill.FromChart(AChart, AElement, AIndex);
|
||||||
Border.FromChart(AChart, AElement, AIndex);
|
Border.FromChart(AChart, AElement, AIndex);
|
||||||
if (AChart.Series[AIndex] is TsBarSeries) then
|
|
||||||
BarSeriesKind := TsBarSeries(AChart.Series[AIndex]).Kind
|
|
||||||
else
|
|
||||||
BarSeriesKind := bskColumns; // Dummy value for non-bar series.
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TsChartSeriesRec.ToChart(AChart: TsChart; AElement: TsChartStyleElement;
|
procedure TsChartSeriesRec.ToChart(AChart: TsChart; AElement: TsChartStyleElement;
|
||||||
@ -661,14 +656,11 @@ begin
|
|||||||
Line.ToChart(AChart, ceSeriesLine, AIndex);
|
Line.ToChart(AChart, ceSeriesLine, AIndex);
|
||||||
Fill.ToChart(AChart, ceSeriesFill, AIndex);
|
Fill.ToChart(AChart, ceSeriesFill, AIndex);
|
||||||
Border.ToChart(AChart, ceSeriesBorder, AIndex);
|
Border.ToChart(AChart, ceSeriesBorder, AIndex);
|
||||||
if (AChart.Series[AIndex] is TsBarSeries) then
|
|
||||||
TsBarSeries(AChart.Series[AIndex]).Kind := BarSeriesKind;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class operator TsChartSeriesRec.= (A, B: TsChartSeriesRec): Boolean;
|
class operator TsChartSeriesRec.= (A, B: TsChartSeriesRec): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := (A.Line = B.Line) and (A.Fill = B.Fill) and (A.Border = B.Border) and
|
Result := (A.Line = B.Line) and (A.Fill = B.Fill) and (A.Border = B.Border);
|
||||||
(A.BarSeriesKind = B.BarSeriesKind);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -7185,7 +7185,9 @@ end;
|
|||||||
function TsSpreadOpenDocWriter.GetChartAxisStyleAsXML(
|
function TsSpreadOpenDocWriter.GetChartAxisStyleAsXML(
|
||||||
Axis: TsChartAxis; AIndent, AStyleID: Integer): String;
|
Axis: TsChartAxis; AIndent, AStyleID: Integer): String;
|
||||||
var
|
var
|
||||||
|
chart: TsChart;
|
||||||
indent: String;
|
indent: String;
|
||||||
|
angle: Integer;
|
||||||
textProps: String = '';
|
textProps: String = '';
|
||||||
graphProps: String = '';
|
graphProps: String = '';
|
||||||
chartProps: String = '';
|
chartProps: String = '';
|
||||||
@ -7194,6 +7196,8 @@ begin
|
|||||||
if not Axis.Visible then
|
if not Axis.Visible then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
chart := Axis.Chart;
|
||||||
|
|
||||||
if Axis.ShowLabels then
|
if Axis.ShowLabels then
|
||||||
chartProps := chartProps + 'chart:display-label="true" ';
|
chartProps := chartProps + 'chart:display-label="true" ';
|
||||||
|
|
||||||
@ -7203,8 +7207,14 @@ begin
|
|||||||
if Axis.Inverted then
|
if Axis.Inverted then
|
||||||
chartProps := chartProps + 'chart:reverse-direction="true" ';
|
chartProps := chartProps + 'chart:reverse-direction="true" ';
|
||||||
|
|
||||||
if Axis.LabelRotation <> 0 then
|
angle := Axis.LabelRotation;
|
||||||
chartProps := chartProps + Format('style:rotation-angle="%d" ', [Axis.LabelRotation]);
|
{
|
||||||
|
if chart.RotatedAxes then
|
||||||
|
begin
|
||||||
|
if angle = 0 then angle := 90 else if angle = 90 then angle := 0;
|
||||||
|
end;
|
||||||
|
}
|
||||||
|
chartProps := chartProps + Format('style:rotation-angle="%d" ', [angle]);
|
||||||
|
|
||||||
graphProps := 'svg:stroke-color="' + ColorToHTMLColorStr(Axis.AxisLine.Color) + '" ';
|
graphProps := 'svg:stroke-color="' + ColorToHTMLColorStr(Axis.AxisLine.Color) + '" ';
|
||||||
|
|
||||||
@ -7259,7 +7269,6 @@ var
|
|||||||
font: TsFont;
|
font: TsFont;
|
||||||
indent: String;
|
indent: String;
|
||||||
rotAngle: Integer;
|
rotAngle: Integer;
|
||||||
visible: Boolean;
|
|
||||||
chartProps: String = '';
|
chartProps: String = '';
|
||||||
textProps: String = '';
|
textProps: String = '';
|
||||||
begin
|
begin
|
||||||
@ -7271,7 +7280,6 @@ begin
|
|||||||
if ACaptionKind = 1 then title := AChart.Title else title := AChart.Subtitle;
|
if ACaptionKind = 1 then title := AChart.Title else title := AChart.Subtitle;
|
||||||
font := title.Font;
|
font := title.Font;
|
||||||
rotAngle := title.RotationAngle;
|
rotAngle := title.RotationAngle;
|
||||||
visible := title.Visible;
|
|
||||||
end;
|
end;
|
||||||
3, 4, 5, 6:
|
3, 4, 5, 6:
|
||||||
begin
|
begin
|
||||||
@ -7283,14 +7291,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
font := axis.CaptionFont;
|
font := axis.CaptionFont;
|
||||||
rotAngle := axis.CaptionRotation;
|
rotAngle := axis.CaptionRotation;
|
||||||
visible := axis.Visible;
|
if AChart.RotatedAxes then
|
||||||
|
begin
|
||||||
|
if rotAngle = 0 then rotAngle := 90 else if rotAngle = 90 then rotAngle := 0;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
else
|
else
|
||||||
raise Exception.Create('[GetChartCaptionStyleAsXML] Unknown caption.');
|
raise Exception.Create('[GetChartCaptionStyleAsXML] Unknown caption.');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
chartProps := 'chart:auto-position="true" ';
|
chartProps := 'chart:auto-position="true" ';
|
||||||
if rotAngle <> 0 then
|
|
||||||
chartProps := chartProps + Format('style:rotation-angle="%d" ', [rotAngle]);
|
chartProps := chartProps + Format('style:rotation-angle="%d" ', [rotAngle]);
|
||||||
|
|
||||||
textProps := WriteFontStyleXMLAsString(font);
|
textProps := WriteFontStyleXMLAsString(font);
|
||||||
@ -7422,9 +7432,7 @@ var
|
|||||||
begin
|
begin
|
||||||
indent := DupeString(' ', AIndent);
|
indent := DupeString(' ', AIndent);
|
||||||
|
|
||||||
if (AChart.Series.Count > 0) and (AChart.Series[0] is TsBarSeries) and
|
if (AChart.Series.Count > 0) and (AChart.Series[0] is TsBarSeries) and AChart.RotatedAxes then
|
||||||
(TsBarSeries(AChart.Series[0]).Kind = bskBars)
|
|
||||||
then
|
|
||||||
verticalStr := 'chart:vertical="true" ';
|
verticalStr := 'chart:vertical="true" ';
|
||||||
|
|
||||||
Result := Format(
|
Result := Format(
|
||||||
|
Reference in New Issue
Block a user