Skip to content

Fix CategoryAxis labels not visible on Android XXHDPI devices #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 16, 2025

Problem

Category X-axis labels were not visible on Android devices with XXHDPI screen density (density value of 3.0), while they displayed correctly on devices with lower density values.

Missing labels on XXHDPI device

Affected Devices

  • Working: Pixel 7 (density 2.625), Redmi Note 11 Pro 5G (density 2.75)
  • Broken: Samsung Galaxy A14 5G (density 3.0), OnePlus Nord CE4 lite (density 3.0)

Root Cause

The issue was in the Android-specific positioning logic in HorizontalLabelLayout.OnDraw() method in AxisLabelLayout.cs:

// Line 410-411: Forces actualSize height to DesiredHeight
actualSize = new SizeF(actualSize.Width, (float)DesiredHeight);

// Line 427: Uses DesiredHeight for positioning
float textY = ((float)yPos + MarginTop + (float)DesiredHeight / 2);

On XXHDPI devices, the DesiredHeight calculation was affected by density scaling, causing labels to be positioned outside the visible chart area.

Solution

Modified the positioning logic to use the original label height instead of the density-scaled DesiredHeight:

SizeF originalActualSize = actualSize; // Store original size
#if ANDROID
actualSize = new SizeF(actualSize.Width, (float)DesiredHeight);
#endif

// Use original height for consistent positioning across all densities
#if ANDROID
float textY = ((float)yPos + MarginTop + originalActualSize.Height / 2);
#else
float textY = yPos + MarginTop;
#endif

Impact

  • Fixed: XXHDPI devices now show category axis labels correctly
  • Preserved: No regression on lower density devices
  • Consistent: Uniform positioning logic across all Android density values
  • Platform-safe: Other platforms (iOS, Windows) unchanged

Testing

Validated positioning improvements:

  • Density 2.625-2.75: Maintains existing behavior (0-1px difference)
  • Density 3.0: Improved positioning by ~5px, bringing labels into visible area

Fixes #218.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Chart Axis labels not visible on Android devices with specific density for category axis Fix CategoryAxis labels not visible on Android XXHDPI devices Jul 16, 2025
@Copilot Copilot AI requested a review from PaulAndersonS July 16, 2025 05:27
Copilot finished work on behalf of PaulAndersonS July 16, 2025 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Chart Axis labels not visible on Android devices with specific density for category axis
2 participants