TAChart: Replace TCustomChartSeries.ColorOrDefault with global ColorDef function

git-svn-id: trunk@31391 -
This commit is contained in:
ask 2011-06-26 06:29:49 +00:00
parent a29bc6b797
commit 2cca7ee1a8
4 changed files with 12 additions and 21 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;