Skip to content

Commit c950a6a

Browse files
committed
enhance: do not allow labels overlap the previous one
Signed-off-by: leo <longshuang@msn.cn>
1 parent a2217ea commit c950a6a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎src/Views/PieChart.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ public bool TryAppend(Label info, double desiredTop)
297297

298298
var midY = (_labels[0].AlignPoint.Y + info.AlignPoint.Y) * 0.5;
299299
var height = Math.Ceiling(_labels.Count / 2.0) * LABEL_HEIGHT;
300-
_bottomY = midY + height * 0.5;
300+
_bottomY = Math.Max(midY + height * 0.5, _labels[0].AlignPoint.Y + height - LABEL_HEIGHT * 0.5);
301301
return true;
302302
}
303303

@@ -324,7 +324,7 @@ public void Draw(DrawingContext context, bool isLeftSide)
324324
var midY = (first.AlignPoint.Y + last.AlignPoint.Y) * 0.5;
325325
var requiredHeight = Math.Ceiling(_labels.Count / 2.0) * LABEL_HEIGHT;
326326
var alignedX = first.AlignPoint.X;
327-
var startY = midY - requiredHeight * 0.5;
327+
var startY = Math.Max(midY - requiredHeight * 0.5, first.AlignPoint.Y - LABEL_HEIGHT * 0.5);
328328
var startX = 0.0;
329329

330330
for (var i = 0; i < _labels.Count; i++)

0 commit comments

Comments
 (0)