mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 08:36:21 +02:00
TAChart: Replace some hard-coded colors by user-changeable properties.
patch by: Alexander Klenin part 2 of issue #13196 git-svn-id: trunk@18730 -
This commit is contained in:
parent
c42b11a253
commit
4f120b8014
@ -236,7 +236,8 @@ begin
|
||||
FPie := TPieSeries.Create(Chart1);
|
||||
Chart1.AddSerie(FPie);
|
||||
FPie.Title := 'pie';
|
||||
FPie.SeriesColor := clRed;
|
||||
FPie.LabelBackgroundColor := $80FFFF;
|
||||
FPie.LabelToPieLinkColor := clCream;
|
||||
FPie.MarksStyle := smsLabelPercent;
|
||||
end;
|
||||
|
||||
|
@ -190,6 +190,9 @@ type
|
||||
TPieSeries = class(TChartSeries)
|
||||
private
|
||||
ColorIndex: Integer;
|
||||
FMiscColors: array [1..3] of TColor;
|
||||
function GetMiscColor(AIndex: integer): TColor;
|
||||
procedure SetMiscColor(AIndex: integer; const AValue: TColor);
|
||||
protected
|
||||
procedure DrawLegend(ACanvas: TCanvas; const ARect: TRect); override;
|
||||
function GetLegendCount: Integer; override;
|
||||
@ -207,6 +210,12 @@ type
|
||||
published
|
||||
property Title;
|
||||
property Active;
|
||||
property LabelTextColor: TColor index 1
|
||||
read GetMiscColor write SetMiscColor default clBlack;
|
||||
property LabelBackgroundColor: TColor index 2
|
||||
read GetMiscColor write SetMiscColor default clYellow;
|
||||
property LabelToPieLinkColor: TColor index 3
|
||||
read GetMiscColor write SetMiscColor default clWhite;
|
||||
end;
|
||||
|
||||
{ TAreaSeries }
|
||||
@ -1382,17 +1391,17 @@ begin
|
||||
b := LineEndPoint(center, prevAngle + angleStep / 2, radius + MARKS_DIST);
|
||||
|
||||
// line from mark to pie
|
||||
ACanvas.Pen.Color := clWhite;
|
||||
ACanvas.Pen.Color := LabelToPieLinkColor;
|
||||
ACanvas.MoveTo(a.x, a.y);
|
||||
ACanvas.LineTo(b.x, b.y);
|
||||
ACanvas.Pen.Color := clBlack;
|
||||
|
||||
if b.x < center.x then
|
||||
b.x -= labelWidths[i];
|
||||
if b.y < center.y then
|
||||
b.y -= labelHeights[i];
|
||||
|
||||
ACanvas.Brush.Color := clYellow;
|
||||
ACanvas.Pen.Color := LabelTextColor;
|
||||
ACanvas.Brush.Color := LabelBackgroundColor;
|
||||
ACanvas.Rectangle(
|
||||
b.x - MarkXMargin, b.y - MarkYMargin,
|
||||
b.x + labelWidths[i] + MarkXMargin, b.y + labelHeights[i] + MarkYMargin);
|
||||
@ -1439,11 +1448,23 @@ begin
|
||||
Result := Max(ACanvas.TextWidth(Format('%1.2g %s', [y, Text])), Result);
|
||||
end;
|
||||
|
||||
function TPieSeries.GetMiscColor(AIndex: integer): TColor;
|
||||
begin
|
||||
Result := FMiscColors[AIndex];
|
||||
end;
|
||||
|
||||
function TPieSeries.GetSeriesColor: TColor;
|
||||
begin
|
||||
Result := clBlack; // SeriesColor is meaningless for PieSeries
|
||||
end;
|
||||
|
||||
procedure TPieSeries.SetMiscColor(AIndex: integer; const AValue: TColor);
|
||||
begin
|
||||
if FMiscColors[AIndex] = AValue then exit;
|
||||
FMiscColors[AIndex] := AValue;
|
||||
UpdateParentChart;
|
||||
end;
|
||||
|
||||
|
||||
procedure TPieSeries.SetSeriesColor(const AValue: TColor);
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user