mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-14 13:59:34 +02:00
TAChart: Replace TCustomChartSeries.ColorOrDefault with global ColorDef function
git-svn-id: trunk@31391 -
This commit is contained in:
parent
a29bc6b797
commit
2cca7ee1a8
@ -124,7 +124,6 @@ type
|
||||
procedure AfterAdd; override;
|
||||
procedure AfterDraw; override;
|
||||
procedure BeforeDraw; override;
|
||||
function ColorOrDefault(AColor: TColor; ADefault: TColor = clTAColor): TColor;
|
||||
procedure GetBounds(var ABounds: TDoubleRect); override;
|
||||
function GetGraphPoint(AIndex: Integer): TDoublePoint;
|
||||
function GetGraphPointX(AIndex: Integer): Double; inline;
|
||||
@ -507,15 +506,6 @@ begin
|
||||
ListSource.Clear;
|
||||
end;
|
||||
|
||||
function TChartSeries.ColorOrDefault(AColor: TColor; ADefault: TColor): TColor;
|
||||
begin
|
||||
Result := AColor;
|
||||
if Result <> clTAColor then exit;
|
||||
Result := ADefault;
|
||||
if Result <> clTAColor then exit;
|
||||
Result := GetSeriesColor;
|
||||
end;
|
||||
|
||||
function TChartSeries.Count: Integer;
|
||||
begin
|
||||
Result := Source.Count;
|
||||
@ -570,7 +560,7 @@ end;
|
||||
|
||||
function TChartSeries.GetColor(AIndex: Integer): TColor;
|
||||
begin
|
||||
Result := ColorOrDefault(Source[AIndex]^.Color);
|
||||
Result := ColorDef(Source[AIndex]^.Color, GetSeriesColor);
|
||||
end;
|
||||
|
||||
function TChartSeries.GetGraphPoint(AIndex: Integer): TDoublePoint;
|
||||
|
@ -150,6 +150,7 @@ type
|
||||
|
||||
function ChartColorToFPColor(AChartColor: TChartColor): TFPColor;
|
||||
function FPColorToChartColor(AFPColor: TFPColor): TChartColor;
|
||||
function ColorDef(AColor, ADefaultColor: TChartColor): TChartColor; inline;
|
||||
|
||||
implementation
|
||||
|
||||
@ -186,6 +187,11 @@ begin
|
||||
((AFPColor.blue shl 8) and $FF0000);
|
||||
end;
|
||||
|
||||
function ColorDef(AColor, ADefaultColor: TChartColor): TChartColor;
|
||||
begin
|
||||
Result := IfThen(AColor = clTAColor, ADefaultColor, AColor);
|
||||
end;
|
||||
|
||||
{ TChartTextOut }
|
||||
|
||||
function TChartTextOut.Alignment(AAlignment: TAlignment): TChartTextOut;
|
||||
|
@ -306,7 +306,7 @@ procedure TLegendItemBrushRect.Draw(ADrawer: IChartDrawer; const ARect: TRect);
|
||||
begin
|
||||
inherited Draw(ADrawer, ARect);
|
||||
if FBrush = nil then
|
||||
ADrawer.SetBrushParams(bsSolid, IfThen(Color = clTAColor, clRed, Color))
|
||||
ADrawer.SetBrushParams(bsSolid, ColorDef(Color, clRed))
|
||||
else begin
|
||||
ADrawer.Brush := FBrush;
|
||||
if Color <> clTAColor then
|
||||
|
@ -132,13 +132,9 @@ uses
|
||||
procedure TLegendItemPieSlice.Draw(ADrawer: IChartDrawer; const ARect: TRect);
|
||||
const
|
||||
ANGLE = 30 * 16;
|
||||
var
|
||||
bc: TChartColor = clRed;
|
||||
begin
|
||||
inherited Draw(ADrawer, ARect);
|
||||
if Color <> clTAColor then
|
||||
bc := Color;
|
||||
ADrawer.SetBrushParams(bsSolid, bc);
|
||||
ADrawer.SetBrushParams(bsSolid, ColorDef(Color, clRed));
|
||||
ADrawer.RadialPie(
|
||||
2 * ARect.Left - ARect.Right, ARect.Top, ARect.Right, ARect.Bottom,
|
||||
-ANGLE, 2 * ANGLE);
|
||||
@ -307,13 +303,12 @@ end;
|
||||
|
||||
function TCustomPieSeries.SliceColor(AIndex: Integer): TColor;
|
||||
const
|
||||
SLICE_COLORS: array [1..15] of TColor = (
|
||||
SLICE_COLORS: array [0..14] of TColor = (
|
||||
clRed, clGreen, clYellow, clBlue, clWhite, clGray, clFuchsia,
|
||||
clTeal, clNavy, clMaroon, clLime, clOlive, clPurple, clSilver, clAqua);
|
||||
begin
|
||||
Result :=
|
||||
ColorOrDefault(
|
||||
Source[AIndex]^.Color, SLICE_COLORS[AIndex mod High(SLICE_COLORS) + 1]);
|
||||
Result := ColorDef(
|
||||
Source[AIndex]^.Color, SLICE_COLORS[AIndex mod Length(SLICE_COLORS)]);
|
||||
end;
|
||||
|
||||
function TCustomPieSeries.TryRadius(ADrawer: IChartDrawer): TRect;
|
||||
|
Loading…
Reference in New Issue
Block a user