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).Symbol := cssCircle;
|
||||
end;
|
||||
if (ser is TsBarSeries) then
|
||||
begin
|
||||
TsBarSeries(ser).Kind := bskBars;
|
||||
end;
|
||||
|
||||
// Add second series
|
||||
ser := SERIES_CLASS.Create(ch);
|
||||
@ -67,6 +63,7 @@ begin
|
||||
ch.Background.Style := fsSolidFill;
|
||||
ch.Border.Style := clsSolid;
|
||||
ch.PlotArea.Background.Style := fsSolidFill;
|
||||
ch.RotatedAxes := true;
|
||||
|
||||
ch.XAxis.ShowLabels := true;
|
||||
ch.XAxis.LabelFont.Size := 8;
|
||||
|
@ -230,14 +230,9 @@ type
|
||||
end;
|
||||
TsChartSeriesClass = class of TsChartSeries;
|
||||
|
||||
TsBarSeriesKind = (bskColumns, bskBars);
|
||||
|
||||
TsBarSeries = class(TsChartSeries)
|
||||
private
|
||||
FKind: TsBarSeriesKind;
|
||||
public
|
||||
constructor Create(AChart: TsChart); override;
|
||||
property Kind: TsBarSeriesKind read FKind write FKind;
|
||||
end;
|
||||
|
||||
TsChartSeriesSymbol = (
|
||||
@ -288,6 +283,8 @@ type
|
||||
FYAxis: TsChartAxis;
|
||||
FY2Axis: TsChartAxis;
|
||||
|
||||
FRotatedAxes: Boolean; // For bar series: vertical columns <--> horizontal bars
|
||||
|
||||
FTitle: TsChartText;
|
||||
FSubTitle: TsChartText;
|
||||
FLegend: TsChartLegend;
|
||||
@ -353,6 +350,8 @@ type
|
||||
property YAxis: TsChartAxis read FYAxis write FYAxis;
|
||||
{ Attributes of the plot's secondary y axis (right) }
|
||||
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;
|
||||
|
||||
|
@ -115,7 +115,6 @@ type
|
||||
Line: TsChartLineRec;
|
||||
Fill: TsChartFillRec;
|
||||
Border: TsChartFillRec;
|
||||
BarSeriesKind: TsBarSeriesKind;
|
||||
procedure FromChart(AChart: TsChart; AElement: TsChartStyleElement; AIndex: Integer);
|
||||
procedure ToChart(AChart: TsChart; AElement: TsChartStyleElement; AIndex: Integer);
|
||||
class operator = (A, B: TsChartSeriesRec): Boolean;
|
||||
@ -649,10 +648,6 @@ begin
|
||||
Line.FromChart(AChart, AElement, AIndex);
|
||||
Fill.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;
|
||||
|
||||
procedure TsChartSeriesRec.ToChart(AChart: TsChart; AElement: TsChartStyleElement;
|
||||
@ -661,14 +656,11 @@ begin
|
||||
Line.ToChart(AChart, ceSeriesLine, AIndex);
|
||||
Fill.ToChart(AChart, ceSeriesFill, AIndex);
|
||||
Border.ToChart(AChart, ceSeriesBorder, AIndex);
|
||||
if (AChart.Series[AIndex] is TsBarSeries) then
|
||||
TsBarSeries(AChart.Series[AIndex]).Kind := BarSeriesKind;
|
||||
end;
|
||||
|
||||
class operator TsChartSeriesRec.= (A, B: TsChartSeriesRec): Boolean;
|
||||
begin
|
||||
Result := (A.Line = B.Line) and (A.Fill = B.Fill) and (A.Border = B.Border) and
|
||||
(A.BarSeriesKind = B.BarSeriesKind);
|
||||
Result := (A.Line = B.Line) and (A.Fill = B.Fill) and (A.Border = B.Border);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -7185,7 +7185,9 @@ end;
|
||||
function TsSpreadOpenDocWriter.GetChartAxisStyleAsXML(
|
||||
Axis: TsChartAxis; AIndent, AStyleID: Integer): String;
|
||||
var
|
||||
chart: TsChart;
|
||||
indent: String;
|
||||
angle: Integer;
|
||||
textProps: String = '';
|
||||
graphProps: String = '';
|
||||
chartProps: String = '';
|
||||
@ -7194,6 +7196,8 @@ begin
|
||||
if not Axis.Visible then
|
||||
exit;
|
||||
|
||||
chart := Axis.Chart;
|
||||
|
||||
if Axis.ShowLabels then
|
||||
chartProps := chartProps + 'chart:display-label="true" ';
|
||||
|
||||
@ -7203,8 +7207,14 @@ begin
|
||||
if Axis.Inverted then
|
||||
chartProps := chartProps + 'chart:reverse-direction="true" ';
|
||||
|
||||
if Axis.LabelRotation <> 0 then
|
||||
chartProps := chartProps + Format('style:rotation-angle="%d" ', [Axis.LabelRotation]);
|
||||
angle := 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) + '" ';
|
||||
|
||||
@ -7259,7 +7269,6 @@ var
|
||||
font: TsFont;
|
||||
indent: String;
|
||||
rotAngle: Integer;
|
||||
visible: Boolean;
|
||||
chartProps: String = '';
|
||||
textProps: String = '';
|
||||
begin
|
||||
@ -7271,7 +7280,6 @@ begin
|
||||
if ACaptionKind = 1 then title := AChart.Title else title := AChart.Subtitle;
|
||||
font := title.Font;
|
||||
rotAngle := title.RotationAngle;
|
||||
visible := title.Visible;
|
||||
end;
|
||||
3, 4, 5, 6:
|
||||
begin
|
||||
@ -7283,15 +7291,17 @@ begin
|
||||
end;
|
||||
font := axis.CaptionFont;
|
||||
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;
|
||||
else
|
||||
raise Exception.Create('[GetChartCaptionStyleAsXML] Unknown caption.');
|
||||
end;
|
||||
|
||||
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);
|
||||
|
||||
@ -7422,9 +7432,7 @@ var
|
||||
begin
|
||||
indent := DupeString(' ', AIndent);
|
||||
|
||||
if (AChart.Series.Count > 0) and (AChart.Series[0] is TsBarSeries) and
|
||||
(TsBarSeries(AChart.Series[0]).Kind = bskBars)
|
||||
then
|
||||
if (AChart.Series.Count > 0) and (AChart.Series[0] is TsBarSeries) and AChart.RotatedAxes then
|
||||
verticalStr := 'chart:vertical="true" ';
|
||||
|
||||
Result := Format(
|
||||
|
Reference in New Issue
Block a user