mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-31 05:12:31 +02:00
Merged revision(s) 47343 #25a3227bc9, 47348 #4f51ba5b51 from trunk:
TAChart: Modify TBoxAndWhiskerSeries.AddXY to use correct YCount value. ........ TAChart: Improvements of Box-Whisker series (no crash on NaN, new prop WidthStyle, respect data point color) ........ git-svn-id: branches/fixes_1_4@47362 -
This commit is contained in:
parent
0c5af88a2d
commit
50dfb45e35
@ -47,6 +47,8 @@ type
|
||||
procedure GetLegendItems(AItems: TChartLegendItems); override;
|
||||
function GetSeriesColor: TColor; override;
|
||||
public
|
||||
function AddXY(AX, AY, ARadius: Double; AXLabel: String = '';
|
||||
AColor: TColor = clTAColor): Integer; overload;
|
||||
procedure Assign(ASource: TPersistent); override;
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
@ -64,6 +66,7 @@ type
|
||||
end;
|
||||
|
||||
TBoxAndWhiskerSeriesLegendDir = (bwlHorizontal, bwlVertical, bwlAuto);
|
||||
TBoxAndWhiskerSeriesWidthStyle = (bwsPercent, bwsPercentMin);
|
||||
|
||||
TBoxAndWhiskerSeries = class(TBasicPointSeries)
|
||||
strict private
|
||||
@ -74,6 +77,7 @@ type
|
||||
FMedianPen: TPen;
|
||||
FWhiskersPen: TPen;
|
||||
FWhiskersWidth: Integer;
|
||||
FWidthStyle: TBoxAndWhiskerSeriesWidthStyle;
|
||||
procedure SetBoxBrush(AValue: TBrush);
|
||||
procedure SetBoxPen(AValue: TPen);
|
||||
procedure SetBoxWidth(AValue: Integer);
|
||||
@ -91,7 +95,6 @@ type
|
||||
procedure Assign(ASource: TPersistent); override;
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
|
||||
procedure Draw(ADrawer: IChartDrawer); override;
|
||||
function Extent: TDoubleRect; override;
|
||||
published
|
||||
@ -102,6 +105,8 @@ type
|
||||
property LegendDirection: TBoxAndWhiskerSeriesLegendDir
|
||||
read FLegendDirection write SetLegendDirection default bwlHorizontal;
|
||||
property MedianPen: TPen read FMedianPen write SetMedianPen;
|
||||
property WidthStyle: TBoxAndWhiskerSeriesWidthStyle
|
||||
read FWidthStyle write FWidthStyle default bwsPercent;
|
||||
property WhiskersPen: TPen read FWhiskersPen write SetWhiskersPen;
|
||||
property WhiskersWidth: Integer
|
||||
read FWhiskersWidth write SetWhiskersWidth default DEF_WHISKERS_WIDTH;
|
||||
@ -334,8 +339,16 @@ begin
|
||||
ADrawer.Line(symbol[5].TopLeft, symbol[5].BottomRight);
|
||||
end;
|
||||
|
||||
|
||||
{ TBubbleSeries }
|
||||
|
||||
function TBubbleSeries.AddXY(AX, AY, ARadius: Double; AXLabel: String;
|
||||
AColor: TColor): Integer;
|
||||
begin
|
||||
if ListSource.YCount < 2 then ListSource.YCount := 2;
|
||||
Result := AddXY(AX, AY, [ARadius], AXLabel, AColor);
|
||||
end;
|
||||
|
||||
procedure TBubbleSeries.Assign(ASource: TPersistent);
|
||||
begin
|
||||
if ASource is TBubbleSeries then
|
||||
@ -446,6 +459,7 @@ function TBoxAndWhiskerSeries.AddXY(
|
||||
AX, AYLoWhisker, AYLoBox, AY, AYHiBox, AYHiWhisker: Double; AXLabel: String;
|
||||
AColor: TColor): Integer;
|
||||
begin
|
||||
if ListSource.YCount < 5 then ListSource.YCount := 5;
|
||||
Result := AddXY(
|
||||
AX, AYLoWhisker, [AYLoBox, AY, AYHiBox, AYHiWhisker], AXLabel, AColor);
|
||||
end;
|
||||
@ -518,7 +532,10 @@ var
|
||||
x, ymin, yqmin, ymed, yqmax, ymax, wb, ww, w: Double;
|
||||
i: Integer;
|
||||
begin
|
||||
if IsEmpty or (Source.YCount < 5) then exit;
|
||||
if IsEmpty or (Source.YCount < 5) then
|
||||
exit;
|
||||
if FWidthStyle = bwsPercentMin then
|
||||
UpdateMinXRange;
|
||||
|
||||
ext2 := ParentChart.CurrentExtent;
|
||||
ExpandRange(ext2.a.X, ext2.b.X, 1.0);
|
||||
@ -529,13 +546,18 @@ begin
|
||||
for i := FLoBound to FUpBound do begin
|
||||
x := GetGraphPointX(i);
|
||||
ymin := GetGraphPointY(i);
|
||||
if IsNaN(x) or IsNaN(ymin) then
|
||||
continue;
|
||||
with Source[i]^ do begin
|
||||
yqmin := AxisToGraphY(YList[0]);
|
||||
ymed := AxisToGraphY(YList[1]);
|
||||
yqmax := AxisToGraphY(YList[2]);
|
||||
ymax := AxisToGraphY(YList[3]);
|
||||
if IsNaN(YList[0]) then continue else yqmin := AxisToGraphY(YList[0]);
|
||||
if IsNaN(YList[1]) then continue else ymed := AxisToGraphY(YList[1]);
|
||||
if IsNaN(YList[2]) then continue else yqmax := AxisToGraphY(YList[2]);
|
||||
if IsNaN(YList[3]) then continue else ymax := AxisToGraphY(YList[3]);
|
||||
end;
|
||||
case FWidthStyle of
|
||||
bwsPercent: w := GetXRange(x, i) * PERCENT / 2;
|
||||
bwsPercentMin: w := FMinXRange * PERCENT / 2;
|
||||
end;
|
||||
w := GetXRange(x, i) * PERCENT / 2;
|
||||
wb := w * BoxWidth;
|
||||
ww := w * WhiskersWidth;
|
||||
|
||||
@ -546,7 +568,10 @@ begin
|
||||
DoLine(x - ww, ymax, x + ww, ymax);
|
||||
DoLine(x, ymax, x, yqmax);
|
||||
ADrawer.Pen := BoxPen;
|
||||
ADrawer.Brush:= BoxBrush;
|
||||
if Source[i]^.Color <> clTAColor then
|
||||
ADrawer.SetBrushParams(bsSolid, Source[i]^.Color)
|
||||
else
|
||||
ADrawer.Brush := BoxBrush;
|
||||
DoRect(x - wb, yqmin, x + wb, yqmax);
|
||||
ADrawer.Pen := MedianPen;
|
||||
ADrawer.SetBrushParams(bsClear, clTAColor);
|
||||
|
Loading…
Reference in New Issue
Block a user