fpspreadsheet: Fix default brushes and pens in stock series.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9271 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2024-03-05 22:39:19 +00:00
parent 3f0fa39576
commit d459d064e8
3 changed files with 30 additions and 26 deletions

View File

@ -189,7 +189,6 @@ type
Gradient: Integer; // Index into chart's Gradients list
Hatch: Integer; // Index into chart's Hatches list
Image: Integer; // Index into chart's Images list
Transparency: Double; // 0.0 ... 1.0
constructor CreateSolidFill(AColor: TsChartColor);
constructor CreateHatchFill(AHatchIndex: Integer; ABkColor: TsChartColor);
procedure CopyFrom(AFill: TsChartFill);
@ -752,7 +751,9 @@ type
FLowRange: TsChartRange; // close = normal y range
FCandleStickDownFill: TsChartFill;
FCandleStickDownBorder: TsChartLine;
FCandleStickUpFill: TsChartFill;
FCandleStickUpBorder: TsChartLine;
FRangeLine: TsChartLine;
FTickWidthPercent: Integer;
// fill is CandleStickUpFill, line is RangeLine
public
@ -768,11 +769,11 @@ type
procedure SetCloseRange(ASheet1: String; ARow1, ACol1: Cardinal; ASheet2: String; ARow2, ACol2: Cardinal);
property CandleStick: Boolean read FCandleStick write FCandleStick;
property CandleStickDownFill: TsChartFill read FCandleStickDownFill write FCandleStickDownFill;
property CandleStickUpFill: TsChartFill read FFill write FFill;
property CandleStickUpFill: TsChartFill read FCandleStickUpFill write FCandleStickUpFill;
property CandleStickDownBorder: TsChartLine read FCandleStickDownBorder write FCandleStickDownBorder;
property CandleStickUpBorder: TsChartLine read FCandleStickUpBorder write FCandleStickUpBorder;
property TickWidthPercent: Integer read FTickWidthPercent write FTickWidthPercent;
property RangeLine: TsChartLine read FLine write FLine;
property RangeLine: TsChartLine read FRangeLine write FRangeLine;
property OpenRange: TsChartRange read FOpenRange;
property HighRange: TsChartRange read FHighRange;
property LowRange: TsChartRange read FLowRange;
@ -1449,7 +1450,6 @@ begin
Gradient := AFill.Gradient;
Hatch := AFill.Hatch;
Image := AFill.Image;
Transparency := AFill.Transparency;
end;
end;
@ -2746,24 +2746,18 @@ begin
FLowRange := TsChartRange.Create(AChart);
// FFill is CandleStickUp, FLine is RangeLine
FCandleStickDownFill := TsChartFill.Create;
FCandleStickDownFill.Style := cfsSolid;
FCandleStickDownFill.Color := ChartColor(scBlack);
FCandleStickDownBorder := TsChartLine.Create;
FCandleStickDownBorder.Style := clsSolid;
FCandleStickDownBorder.Color := ChartColor(scBlack);
FCandleStickDownBorder.Width := PtsToMM(DEFAULT_CHART_LINEWIDTH);
FCandleStickUpBorder := TsChartLine.Create;
FCandleStickUpBorder.Style := clsSolid;
FCandleStickUpBorder.Color := ChartColor(scBlack);
FCandleStickUpBorder.Width := PtsToMM(DEFAULT_CHART_LINEWIDTH);
FLine.Style := clsSolid;
FLine.Color := ChartColor(scBlack);
FCandleStickDownBorder := TsChartLine.CreateSolid(ChartColor(scBlack), PtsToMM(DEFAULT_CHART_LINEWIDTH));
FCandleStickDownFill := TsChartFill.CreateSolidFill(ChartColor(scBlack)); // These are the Excel default colors
FCandleStickUpBorder := TsChartLine.CreateSolid(ChartColor(scBlack), PtsToMM(DEFAULT_CHART_LINEWIDTH));
FCandleStickUpFill := TsChartFill.CreateSolidFill(ChartColor(scWhite));
FRangeLine := TsChartLine.CreateSolid(ChartColor(scBlack), PtsToMM(DEFAULT_CHART_LINEWIDTH));
FTickWidthPercent := 50;
end;
destructor TsStockSeries.Destroy;
begin
FRangeLine.Free;
FCandleStickUpFill.Free;
FCandleStickUpBorder.Free;
FCandleStickDownBorder.Free;
FCandleStickDownFill.Free;

View File

@ -1378,7 +1378,7 @@ begin
exit;
end;
ser.Transparency := round(ASeries.Fill.Transparency);
ser.Transparency := round(ASeries.Fill.Color.Transparency);
axis := ASeries.Chart.YAxis;
UpdateChartSeriesMarks(ASeries, ser);
if IsStackable(ASeries) then
@ -2000,7 +2000,7 @@ procedure TsWorkbookChartLink.UpdateAreaSeries(AWorkbookSeries: TsAreaSeries;
begin
UpdateChartBrush(AWorkbookSeries.Chart, AWorkbookSeries.Fill, AChartSeries.AreaBrush);
UpdateChartPen(AWorkbookSeries.Chart, AWorkbookSeries.Line, AChartSeries.AreaContourPen);
AChartSeries.Transparency := round(AWorkbookSeries.Fill.Transparency * 255);
AChartSeries.Transparency := round(AWorkbookSeries.Fill.Color.Transparency * 255);
AChartSeries.AreaLinesPen.Style := psClear;
AChartSeries.Stacked := AWorkbookSeries.Chart.StackMode <> csmDefault;
AChartSeries.UseZeroLevel := true;
@ -2038,7 +2038,7 @@ procedure TsWorkbookChartLink.UpdateBarSeries(AWorkbookSeries: TsBarSeries;
begin
UpdateChartBrush(AWorkbookSeries.Chart, AWorkbookSeries.Fill, AChartSeries.BarBrush);
UpdateChartPen(AWorkbookSeries.Chart, AWorkbookSeries.Line, AChartSeries.BarPen);
AChartSeries.Transparency := round(AWorkbookSeries.Fill.Transparency * 255);
AChartSeries.Transparency := round(AWorkbookSeries.Fill.Color.Transparency * 255);
AChartSeries.BarWidthPercent := CalcBarWidthPercent;
AChartSeries.BarOffsetPercent := 0; // TAChart currently does not support offsets in multiple-y bar series.
AChartSeries.BarWidthStyle := bwPercentMin;
@ -2055,7 +2055,7 @@ procedure TsWorkbookChartlink.UpdateBubbleSeries(AWorkbookSeries: TsBubbleSeries
begin
UpdateChartBrush(AWorkbookSeries.Chart, AWorkbookSeries.Fill, AChartSeries.BubbleBrush);
UpdateChartPen(AWorkbookSeries.Chart, AWorkbookSeries.Line, AChartSeries.BubblePen);
AChartSeries.Transparency := round(255*AWorkbookSeries.Fill.Transparency);
AChartSeries.Transparency := round(255*AWorkbookSeries.Fill.Color.Transparency);
AChartSeries.Legend.Multiplicity := lmPoint;
{$IF LCL_FullVersion >= 3990000}
@ -2807,7 +2807,7 @@ var
begin
ppi := GetParentForm(FChart).PixelsPerInch;
AChartSeries.Transparency := round(AWorkbookSeries.Fill.Transparency * 255);
AChartSeries.Transparency := round(AWorkbookSeries.Fill.Color.Transparency * 255);
AChartSeries.CloseCircle := true;
AChartSeries.Filled := (AWorkbookSeries.ChartType = ctFilledRadar);
AChartSeries.ShowPoints := AWorkbookSeries.ShowSymbols;

View File

@ -352,14 +352,24 @@ procedure TStockSeries.Draw(ADrawer: IChartDrawer);
ADrawer.Line(MaybeRotate(AX1, AY1), MaybeRotate(AX2, AY2));
end;
procedure NoZeroRect(var R: TRect);
begin
if IsRotated then
begin
if R.Left = R.Right then inc(R.Right);
end else
begin
if R.Top = R.Bottom then inc(R.Bottom);
end;
end;
procedure DoRect(AX1, AY1, AX2, AY2: Double);
var
r: TRect;
begin
with ParentChart do begin
r.TopLeft := MaybeRotate(AX1, AY1);
r.BottomRight := MaybeRotate(AX2, AY2);
end;
r.TopLeft := MaybeRotate(AX1, AY1);
r.BottomRight := MaybeRotate(AX2, AY2);
NoZeroRect(r);
ADrawer.FillRect(r.Left, r.Top, r.Right, r.Bottom);
ADrawer.Rectangle(r);
end;