mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-03 23:43:49 +02:00
TAChart: Implement legend multiplicity for most series
git-svn-id: trunk@27565 -
This commit is contained in:
parent
a1310c5ca4
commit
213a8b5ef1
@ -50,6 +50,7 @@ object Form1: TForm1
|
|||||||
Source = RandomChartSource1
|
Source = RandomChartSource1
|
||||||
end
|
end
|
||||||
object Chart1PieSeries1: TPieSeries
|
object Chart1PieSeries1: TPieSeries
|
||||||
|
Legend.Multiplicity = lmPoint
|
||||||
Marks.Format = '%1:.2f%%'
|
Marks.Format = '%1:.2f%%'
|
||||||
Marks.Style = smsPercent
|
Marks.Style = smsPercent
|
||||||
Exploded = True
|
Exploded = True
|
||||||
|
@ -5,7 +5,8 @@ unit main;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
ExtCtrls, Spin, StdCtrls, Forms, TAGraph, TASeries, TASources, Classes, TALegend, Graphics;
|
ExtCtrls, Spin, StdCtrls, Forms, TAGraph, TASeries, TASources, Classes,
|
||||||
|
TALegend, Graphics;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
@ -185,6 +185,7 @@ type
|
|||||||
|
|
||||||
procedure DrawLabels(ACanvas: TCanvas);
|
procedure DrawLabels(ACanvas: TCanvas);
|
||||||
function GetLabelDirection(AIndex: Integer): TLabelDirection; virtual;
|
function GetLabelDirection(AIndex: Integer): TLabelDirection; virtual;
|
||||||
|
procedure GetLegendItemsRect(AItems: TChartLegendItems; ABrush: TBrush);
|
||||||
function GetXRange(AX: Double; AIndex: Integer): Double;
|
function GetXRange(AX: Double; AIndex: Integer): Double;
|
||||||
procedure PrepareGraphPoints(
|
procedure PrepareGraphPoints(
|
||||||
const AExtent: TDoubleRect; AFilterByExtent: Boolean);
|
const AExtent: TDoubleRect; AFilterByExtent: Boolean);
|
||||||
@ -704,6 +705,21 @@ begin
|
|||||||
Result := DIR[IsRotated, GetGraphPointY(AIndex) < 0];
|
Result := DIR[IsRotated, GetGraphPointY(AIndex) < 0];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TBasicPointSeries.GetLegendItemsRect(
|
||||||
|
AItems: TChartLegendItems; ABrush: TBrush);
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
case Legend.Multiplicity of
|
||||||
|
lmSingle:
|
||||||
|
AItems.Add(TLegendItemBrushRect.Create(ABrush, Title));
|
||||||
|
lmPoint: begin
|
||||||
|
for i := 0 to Count - 1 do
|
||||||
|
AItems.Add(TLegendItemColorRect.Create(GetColor(i), FormattedMark(i)));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TBasicPointSeries.GetNearestPoint(
|
function TBasicPointSeries.GetNearestPoint(
|
||||||
ADistFunc: TPointDistFunc; const APoint: TPoint;
|
ADistFunc: TPointDistFunc; const APoint: TPoint;
|
||||||
out AIndex: Integer; out AImg: TPoint; out AValue: TDoublePoint): Boolean;
|
out AIndex: Integer; out AImg: TPoint; out AValue: TDoublePoint): Boolean;
|
||||||
|
@ -163,7 +163,7 @@ end;
|
|||||||
|
|
||||||
procedure TBubbleSeries.GetLegendItems(AItems: TChartLegendItems);
|
procedure TBubbleSeries.GetLegendItems(AItems: TChartLegendItems);
|
||||||
begin
|
begin
|
||||||
AItems.Add(TLegendItemBrushRect.Create(BubbleBrush, Title));
|
GetLegendItemsRect(AItems, BubbleBrush);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBubbleSeries.GetSeriesColor: TColor;
|
function TBubbleSeries.GetSeriesColor: TColor;
|
||||||
@ -298,7 +298,7 @@ end;
|
|||||||
|
|
||||||
procedure TBoxAndWhiskerSeries.GetLegendItems(AItems: TChartLegendItems);
|
procedure TBoxAndWhiskerSeries.GetLegendItems(AItems: TChartLegendItems);
|
||||||
begin
|
begin
|
||||||
AItems.Add(TLegendItemBrushRect.Create(BoxBrush, Title));
|
GetLegendItemsRect(AItems, BoxBrush);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBoxAndWhiskerSeries.GetSeriesColor: TColor;
|
function TBoxAndWhiskerSeries.GetSeriesColor: TColor;
|
||||||
|
@ -501,6 +501,7 @@ procedure TLineSeries.GetLegendItems(AItems: TChartLegendItems);
|
|||||||
var
|
var
|
||||||
lp: TPen;
|
lp: TPen;
|
||||||
p: TSeriesPointer;
|
p: TSeriesPointer;
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
if LineType = ltNone then
|
if LineType = ltNone then
|
||||||
lp := nil
|
lp := nil
|
||||||
@ -510,7 +511,14 @@ begin
|
|||||||
p := Pointer
|
p := Pointer
|
||||||
else
|
else
|
||||||
p := nil;
|
p := nil;
|
||||||
AItems.Add(TLegendItemLinePointer.Create(lp, p, Title));
|
case Legend.Multiplicity of
|
||||||
|
lmSingle:
|
||||||
|
AItems.Add(TLegendItemLinePointer.Create(lp, p, Title));
|
||||||
|
lmPoint: begin
|
||||||
|
for i := 0 to Count - 1 do
|
||||||
|
AItems.Add(TLegendItemLinePointer.Create(lp, p, FormattedMark(i)));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TLineSeries.GetSeriesColor: TColor;
|
function TLineSeries.GetSeriesColor: TColor;
|
||||||
@ -807,7 +815,7 @@ end;
|
|||||||
|
|
||||||
procedure TBarSeries.GetLegendItems(AItems: TChartLegendItems);
|
procedure TBarSeries.GetLegendItems(AItems: TChartLegendItems);
|
||||||
begin
|
begin
|
||||||
AItems.Add(TLegendItemBrushRect.Create(BarBrush, Title));
|
GetLegendItemsRect(AItems, BarBrush);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBarSeries.GetSeriesColor: TColor;
|
function TBarSeries.GetSeriesColor: TColor;
|
||||||
@ -1131,7 +1139,7 @@ end;
|
|||||||
|
|
||||||
procedure TAreaSeries.GetLegendItems(AItems: TChartLegendItems);
|
procedure TAreaSeries.GetLegendItems(AItems: TChartLegendItems);
|
||||||
begin
|
begin
|
||||||
AItems.Add(TLegendItemBrushRect.Create(AreaBrush, Title));
|
GetLegendItemsRect(AItems, AreaBrush);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TAreaSeries.GetSeriesColor: TColor;
|
function TAreaSeries.GetSeriesColor: TColor;
|
||||||
|
Loading…
Reference in New Issue
Block a user