mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 01:39:25 +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);
|
FPie := TPieSeries.Create(Chart1);
|
||||||
Chart1.AddSerie(FPie);
|
Chart1.AddSerie(FPie);
|
||||||
FPie.Title := 'pie';
|
FPie.Title := 'pie';
|
||||||
FPie.SeriesColor := clRed;
|
FPie.LabelBackgroundColor := $80FFFF;
|
||||||
|
FPie.LabelToPieLinkColor := clCream;
|
||||||
FPie.MarksStyle := smsLabelPercent;
|
FPie.MarksStyle := smsLabelPercent;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -190,6 +190,9 @@ type
|
|||||||
TPieSeries = class(TChartSeries)
|
TPieSeries = class(TChartSeries)
|
||||||
private
|
private
|
||||||
ColorIndex: Integer;
|
ColorIndex: Integer;
|
||||||
|
FMiscColors: array [1..3] of TColor;
|
||||||
|
function GetMiscColor(AIndex: integer): TColor;
|
||||||
|
procedure SetMiscColor(AIndex: integer; const AValue: TColor);
|
||||||
protected
|
protected
|
||||||
procedure DrawLegend(ACanvas: TCanvas; const ARect: TRect); override;
|
procedure DrawLegend(ACanvas: TCanvas; const ARect: TRect); override;
|
||||||
function GetLegendCount: Integer; override;
|
function GetLegendCount: Integer; override;
|
||||||
@ -207,6 +210,12 @@ type
|
|||||||
published
|
published
|
||||||
property Title;
|
property Title;
|
||||||
property Active;
|
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;
|
end;
|
||||||
|
|
||||||
{ TAreaSeries }
|
{ TAreaSeries }
|
||||||
@ -1382,17 +1391,17 @@ begin
|
|||||||
b := LineEndPoint(center, prevAngle + angleStep / 2, radius + MARKS_DIST);
|
b := LineEndPoint(center, prevAngle + angleStep / 2, radius + MARKS_DIST);
|
||||||
|
|
||||||
// line from mark to pie
|
// line from mark to pie
|
||||||
ACanvas.Pen.Color := clWhite;
|
ACanvas.Pen.Color := LabelToPieLinkColor;
|
||||||
ACanvas.MoveTo(a.x, a.y);
|
ACanvas.MoveTo(a.x, a.y);
|
||||||
ACanvas.LineTo(b.x, b.y);
|
ACanvas.LineTo(b.x, b.y);
|
||||||
ACanvas.Pen.Color := clBlack;
|
|
||||||
|
|
||||||
if b.x < center.x then
|
if b.x < center.x then
|
||||||
b.x -= labelWidths[i];
|
b.x -= labelWidths[i];
|
||||||
if b.y < center.y then
|
if b.y < center.y then
|
||||||
b.y -= labelHeights[i];
|
b.y -= labelHeights[i];
|
||||||
|
|
||||||
ACanvas.Brush.Color := clYellow;
|
ACanvas.Pen.Color := LabelTextColor;
|
||||||
|
ACanvas.Brush.Color := LabelBackgroundColor;
|
||||||
ACanvas.Rectangle(
|
ACanvas.Rectangle(
|
||||||
b.x - MarkXMargin, b.y - MarkYMargin,
|
b.x - MarkXMargin, b.y - MarkYMargin,
|
||||||
b.x + labelWidths[i] + MarkXMargin, b.y + labelHeights[i] + 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);
|
Result := Max(ACanvas.TextWidth(Format('%1.2g %s', [y, Text])), Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TPieSeries.GetMiscColor(AIndex: integer): TColor;
|
||||||
|
begin
|
||||||
|
Result := FMiscColors[AIndex];
|
||||||
|
end;
|
||||||
|
|
||||||
function TPieSeries.GetSeriesColor: TColor;
|
function TPieSeries.GetSeriesColor: TColor;
|
||||||
begin
|
begin
|
||||||
Result := clBlack; // SeriesColor is meaningless for PieSeries
|
Result := clBlack; // SeriesColor is meaningless for PieSeries
|
||||||
end;
|
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);
|
procedure TPieSeries.SetSeriesColor(const AValue: TColor);
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user