TAChart: Publish Marks and MarkPositions for TBubbleSeries. Position 2nd datapoint mark at bubble perimeter.

git-svn-id: trunk@60437 -
This commit is contained in:
wp 2019-02-15 23:32:32 +00:00
parent c0f732d0dd
commit b48e2ca91a
2 changed files with 38 additions and 18 deletions

View File

@ -1313,25 +1313,28 @@ begin
prev := IfThen(FSupportsZeroLevel, GetZeroLevel, 0.0);
for si := 0 to Source.YCount - 1 do begin
g := GetLabelDataPoint(i, si);
if si = 0 then begin
y := Source[i]^.Y;
yIsNaN := IsNaN(y);
ysum := IfThen(yIsNaN, prev, y);
end else begin
y := Source[i]^.YList[si-1];
yIsNaN := IsNaN(y);
if yIsNaN then y := 0.0;
if Stacked then begin
ysum += y;
y := ysum;
if FStacked then begin
if si = 0 then begin
y := Source[i]^.Y;
yIsNaN := IsNaN(y);
ysum := IfThen(yIsNaN, prev, y);
end else begin
y := Source[i]^.YList[si-1];
yIsNaN := IsNaN(y);
if yIsNaN then y := 0.0;
if Stacked then begin
ysum += y;
y := ysum;
end;
end;
end;
if IsRotated then
g.X := AxisToGraphY(y)
// Axis-to-graph transformation is independent of axis rotation ->
// Using AxisToGraph_Y_ is correct!
else
g.Y := AxisToGraphY(y);
if IsRotated then
g.X := AxisToGraphY(y)
// Axis-to-graph transformation is independent of axis rotation ->
// Using AxisToGraph_Y_ is correct!
else
g.Y := AxisToGraphY(y);
end else
yIsNaN := IsNaN(g.y);
curr := TDoublePointBoolArr(g)[not IsRotated];
if FMarkPositionCentered then begin

View File

@ -52,6 +52,7 @@ type
procedure SetOverrideColor(AValue: TBubbleOverrideColors);
protected
function GetBubbleRect(AItem: PChartDataItem; out ARect: TRect): Boolean;
function GetLabelDataPoint(AIndex, AYIndex: Integer): TDoublePoint; override;
procedure GetLegendItems(AItems: TChartLegendItems); override;
function GetSeriesColor: TColor; override;
class procedure GetXYCountNeeded(out AXCount, AYCount: Integer); override;
@ -76,6 +77,8 @@ type
property BubblePen: TPen read FBubblePen write SetBubblePen;
property BubbleRadiusUnits: TBubbleRadiusUnits read FBubbleRadiusUnits
write SetBubbleRadiusUnits default bruXY;
property MarkPositions;
property Marks;
property OverrideColor: TBubbleOverrideColors
read FOverrideColor write SetOverrideColor default [];
property Source;
@ -601,6 +604,20 @@ begin
Result := true;
end;
function TBubbleSeries.GetLabelDataPoint(AIndex, AYIndex: Integer): TDoublePoint;
var
item: PChartDataItem;
R: TRect;
begin
if (AYIndex = 1) and GetBubbleRect(Source.Item[AIndex], R) then begin
if IsRotated then
Result := ParentChart.ImageToGraph(Point(R.Right, (R.Top + R.Bottom) div 2))
else
Result := parentChart.ImageToGraph(Point((R.Left + R.Right) div 2, R.Top));
end else
Result := GetGraphPoint(AIndex, 0, 0);
end;
procedure TBubbleSeries.GetLegendItems(AItems: TChartLegendItems);
begin
GetLegendItemsRect(AItems, BubbleBrush);