You've already forked lazarus-ccr
fpspreadsheet: ods writer supports bar series (vertical and horizontal bars)
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8985 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -25,6 +25,7 @@ begin
|
||||
end;
|
||||
|
||||
ch := b.AddChart(sh1, 4, 4, 160, 100);
|
||||
{
|
||||
ser := TsLineSeries.Create(ch);
|
||||
ser.SetTitleAddr(0, 1);
|
||||
ser.SetLabelRange(1, 0, 7, 0);
|
||||
@ -32,7 +33,15 @@ begin
|
||||
ser.Line.Color := scBlue;
|
||||
TsLineSeries(ser).ShowSymbols := true;
|
||||
TsLineSeries(ser).Symbol := cssCircle;
|
||||
}
|
||||
ser := TsBarSeries.Create(ch);
|
||||
ser.SetTitleAddr(0, 2);
|
||||
ser.SetLabelRange(1, 0, 7, 0);
|
||||
ser.SetYRange(1, 2, 7, 2);
|
||||
ser.Fill.FgColor := scRed;
|
||||
TsBarSeries(ser).Kind := bskBars;
|
||||
|
||||
{
|
||||
ser := TsLineSeries.Create(ch);
|
||||
ser.SetTitleAddr(0, 2);
|
||||
ser.SetLabelRange(1, 0, 7, 0);
|
||||
@ -40,6 +49,7 @@ begin
|
||||
ser.Line.Color := scRed;
|
||||
TsLineSeries(ser).ShowSymbols := true;
|
||||
TsLineSeries(ser).Symbol := cssDiamond;
|
||||
}
|
||||
|
||||
{$IFDEF DARK_MODE}
|
||||
ch.Background.FgColor := scBlack;
|
||||
|
@ -227,6 +227,16 @@ type
|
||||
property Line: TsChartLine read FLine write FLine;
|
||||
end;
|
||||
|
||||
TsBarSeriesKind = (bskColumns, bskBars);
|
||||
|
||||
TsBarSeries = class(TsChartSeries)
|
||||
private
|
||||
FKind: TsBarSeriesKind;
|
||||
public
|
||||
constructor Create(AChart: TsChart);
|
||||
property Kind: TsBarSeriesKind read FKind write FKind;
|
||||
end;
|
||||
|
||||
TsChartSeriesSymbol = (
|
||||
cssRect, cssDiamond, cssTriangle, cssTriangleDown, cssTriangleLeft,
|
||||
cssTriangleRight, cssCircle, cssStar, cssX, cssPlus, cssAsterisk
|
||||
@ -673,6 +683,15 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
{ TsBarSeries }
|
||||
|
||||
constructor TsBarSeries.Create(AChart: TsChart);
|
||||
begin
|
||||
inherited Create(AChart);
|
||||
FChartType := ctBar;
|
||||
end;
|
||||
|
||||
|
||||
{ TsLineSeries }
|
||||
|
||||
constructor TsLineSeries.Create(AChart: TsChart);
|
||||
|
@ -115,6 +115,7 @@ 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;
|
||||
@ -648,6 +649,10 @@ 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;
|
||||
@ -656,11 +661,14 @@ 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);
|
||||
Result := (A.Line = B.Line) and (A.Fill = B.Fill) and (A.Border = B.Border) and
|
||||
(A.BarSeriesKind = B.BarSeriesKind);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -7420,19 +7420,27 @@ function TsSpreadOpenDocWriter.GetChartPlotAreaStyleAsXML(AChart: TsChart;
|
||||
AStyleIndex, AIndent: Integer): String;
|
||||
var
|
||||
ind: String;
|
||||
verticalStr: String = '';
|
||||
begin
|
||||
ind := DupeString(' ', AIndent);
|
||||
|
||||
if (AChart.Series.Count > 0) and (AChart.Series[0] is TsBarSeries) and
|
||||
(TsBarSeries(AChart.Series[0]).Kind = bskBars)
|
||||
then
|
||||
verticalStr := 'chart:vertical="true" ';
|
||||
|
||||
Result := Format(
|
||||
ind + ' <style:style style:name="ch%d" style:family="chart">' + LE +
|
||||
ind + ' <style:chart-properties ' +
|
||||
'chart:symbol-type="automatic" ' +
|
||||
'chart:include-hidden-cells="false" ' +
|
||||
verticalStr +
|
||||
'chart:auto-position="true" ' +
|
||||
'chart:auto-size="true" ' +
|
||||
'chart:treat-empty-cells="leave-gap" ' +
|
||||
'chart:right-angled-axes="true"/>' + LE +
|
||||
ind + ' </style:style>' + LE,
|
||||
[ AStyleIndex ]
|
||||
[ AStyleIndex + 1]
|
||||
);
|
||||
end;
|
||||
|
||||
@ -7583,6 +7591,12 @@ begin
|
||||
GetChartLegendStyleAsXML(AChart, idx, AIndent + 2)
|
||||
);
|
||||
|
||||
// Style for <chart:plot<area>
|
||||
idx := styles.FindStyleIndexByName('PlotArea');
|
||||
AppendToStream(AStream,
|
||||
GetChartPlotAreaStyleAsXML(AChart, idx, AIndent + 2)
|
||||
);
|
||||
|
||||
// Styles for wall and floor
|
||||
idx := styles.FindStyleIndexByName('Wall');
|
||||
AppendToStream(AStream,
|
||||
|
Reference in New Issue
Block a user