Skip to content

Commit effca74

Browse files
Updated the code review suggestions
1 parent 0be9b3c commit effca74

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

maui/src/Charts/Axis/ChartAxis.cs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,25 @@ 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 spacingFactor = GetLabelSpacingFactor();
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+
243261
double adjustedDesiredIntervalsCount = size * spacingFactor * MaximumLabels;
244262
return Math.Max(adjustedDesiredIntervalsCount / 100, 1.0);
245263
}
@@ -776,25 +794,6 @@ void RaiseActualRangeChangedEvent(DoubleRange visibleRange, Size plotSize)
776794
}
777795
}
778796

779-
double GetLabelSpacingFactor()
780-
{
781-
if (IsVertical)
782-
return 1.0;
783-
784-
// Base factor for horizontal labels - more conservative than 0.54
785-
double factor = 0.6;
786-
// Adjust based on label rotation
787-
double rotationRadians = Math.Abs(LabelRotation) * Math.PI / 180;
788-
789-
if (rotationRadians > 0)
790-
{
791-
// Rotated labels can be packed more densely
792-
factor *= 1.0 + 0.3 * Math.Sin(rotationRadians);
793-
}
794-
795-
return factor;
796-
}
797-
798797
#endregion
799798

800799
#endregion

0 commit comments

Comments
 (0)