Skip to content

Commit e636140

Browse files
Merge pull request #242 from syncfusion/axislabelsskipfix
Fixed the issue of Horizontal axis labels skipped despite available space.
2 parents 28922df + effca74 commit e636140

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

maui/src/Charts/Axis/ChartAxis.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,27 @@ public double PointToValue(double x, double y)
239239
protected internal double GetActualDesiredIntervalsCount(Size availableSize)
240240
{
241241
double size = !IsVertical ? availableSize.Width : availableSize.Height;
242-
double adjustedDesiredIntervalsCount = size * (!IsVertical ? 0.54 : 1.0) * MaximumLabels;
243-
var actualDesiredIntervalsCount = Math.Max(adjustedDesiredIntervalsCount / 100, 1.0);
244-
return actualDesiredIntervalsCount;
242+
243+
double spacingFactor = 1.0; //If the Axis is Vertical
244+
245+
if (!IsVertical)
246+
{
247+
// Base factor for horizontal labels
248+
double factor = 0.6;
249+
// Adjust based on label rotation
250+
double rotationRadians = Math.Abs(LabelRotation) * Math.PI / 180;
251+
252+
if (rotationRadians > 0)
253+
{
254+
// Rotated labels can be packed more densely
255+
factor *= 1.0 + 0.3 * Math.Sin(rotationRadians);
256+
}
257+
258+
spacingFactor = factor;
259+
}
260+
261+
double adjustedDesiredIntervalsCount = size * spacingFactor * MaximumLabels;
262+
return Math.Max(adjustedDesiredIntervalsCount / 100, 1.0);
245263
}
246264

247265
/// <summary>

0 commit comments

Comments
 (0)