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