Skip to content

X-axis category labels overlap with long text in XY Chart #7599

@EmnaBarbouch

Description

@EmnaBarbouch

Description

When rendering an xychart with long category labels on the x-axis, the labels overlap without any layout mitigation (rotation, truncation, or wrapping). This results in unreadable axis text and poor chart usability.

Steps to reproduce

  1. Create an XY chart with long category labels
  2. Open the chart in browser http://localhost:9000/xychart.html
  3. Observe the x-axis labels

Screenshots

Image

Code Sample

xychart
  title "Category Overlap Demo"
  x-axis [
    "Category 1 - Lorem ipsum dolor sit amet",
    "Category 2 - Consectetur adipiscing elit sed do eiusmod",
    "Category 3 - Tempor incididunt ut labore et dolore magna aliqua",
    "Category 4 - Ut enim ad minim veniam quis nostrud exercitation"
  ]
  y-axis 0 --> 150
  bar [52, 96, 35, 10]

Setup

  • Mermaid version: 11.13.0
  • Browser and Version: Chrome

Suggested Solutions

Rotate labels by 45° when they exceed available slot width.
Truncate with ellipsis to slot width.

Additional Context

This affects readability and usability of XY charts in real-world datasets where category names are often long ( product names, descriptions, logs).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: TriageNeeds to be verified, categorized, etcType: Bug / ErrorSomething isn't working or is incorrect

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions