mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-16 21:09:30 +02:00
TAChart: Add option (bruPercentageArea) to draw size of bubbles in TBubbleSeries proportional to area rather than radius. Rename bruPercentage to bruPercentageRadius.
This commit is contained in:
parent
a09b37afad
commit
34c8c64d30
@ -41,10 +41,11 @@ type
|
||||
TBubbleOverrideColor = (bocBrush, bocPen);
|
||||
TBubbleOverrideColors = set of TBubbleOverrideColor;
|
||||
TBubbleRadiusUnits = (
|
||||
bruX, // Circle with radius given in x axis units
|
||||
bruY, // Circle with radius given in y axis units
|
||||
bruXY, // Ellipse
|
||||
bruPercentage // Percentage of the smallest dimension of plot area
|
||||
bruX, // Circle with radius given in x axis units
|
||||
bruY, // Circle with radius given in y axis units
|
||||
bruXY, // Ellipse
|
||||
bruPercentageRadius, // Bubble radius is percentage of the smallest dimension of plot area
|
||||
bruPercentageArea // dto., but bubble area
|
||||
);
|
||||
|
||||
{ TBubbleSeries }
|
||||
@ -574,13 +575,18 @@ begin
|
||||
inherited Assign(ASource);
|
||||
end;
|
||||
|
||||
{ Adjusts a scaling factor such that the largest bubble radius is the
|
||||
given percentage (FBubbleRadiusPercentage) of the smallest edge of
|
||||
the chart area (ARect). }
|
||||
function TBubbleSeries.CalcBubbleScalingFactor(const ARect: TRect): Double;
|
||||
var
|
||||
rMin, rMax: Double;
|
||||
begin
|
||||
if FBubbleRadiusUnits = bruPercentage then
|
||||
if FBubbleRadiusUnits in [bruPercentageRadius, bruPercentageArea] then
|
||||
begin
|
||||
Source.YRange(1, rMin, rMax);
|
||||
if FBubbleRadiusUnits = bruPercentageArea then
|
||||
rMax := sqrt(abs(rMax));
|
||||
Result := Min(ARect.Width, ARect.Height) * FBubbleRadiusPercentage * PERCENT / abs(rMax);
|
||||
end else
|
||||
Result := 1.0;
|
||||
@ -737,12 +743,18 @@ begin
|
||||
ARect.TopLeft := ParentChart.GraphToImage(AxisToGraph(DoublePoint(sp.x - r, sp.y - r)));
|
||||
ARect.BottomRight := ParentChart.GraphToImage(AxisToGraph(DoublePoint(sp.x + r, sp.y + r)));
|
||||
end;
|
||||
bruPercentage:
|
||||
bruPercentageRadius:
|
||||
begin
|
||||
p := ParentChart.GraphToImage(AxisToGraph(sp));
|
||||
ri := round(r * AFactor);
|
||||
ARect := Rect(p.x - ri, p.y - ri, p.x + ri, p.y + ri);
|
||||
end;
|
||||
bruPercentageArea:
|
||||
begin
|
||||
p := ParentChart.GraphToImage(AxisToGraph(sp));
|
||||
ri := round(sqrt(abs(r)) * AFactor);
|
||||
ARect := Rect(p.x - ri, p.y - ri, p.x + ri, p.y + ri);
|
||||
end;
|
||||
end;
|
||||
NormalizeRect(ARect);
|
||||
Result := true;
|
||||
|
Loading…
Reference in New Issue
Block a user