Skip to content
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

Timeline LongText wrap #6182

Closed
0xshellming opened this issue Jan 12, 2025 · 3 comments · May be fixed by #6258
Closed

Timeline LongText wrap #6182

0xshellming opened this issue Jan 12, 2025 · 3 comments · May be fixed by #6258
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@0xshellming
Copy link

Description

Timeline text will display out of the color block when it is too long

Steps to reproduce

input long text timeline

Screenshots

image

Code Sample

timeline
    title History of Social Media Platform
    2002 : LongLongLongLongLongLongLongLongLongLongLongLongLongLong
    2004 : Facebook
         : Google
    2005 : Youtube
    2006 : LongLongLongLongLongLongLongLongLongLongLongLongLongLong

Setup

  • Mermaid version:
  • Browser and Version: [Chrome, Edge, Firefox]

Suggested Solutions

Automatically wrap lines and display inside the color block

Additional Context

No response

@0xshellming 0xshellming added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Jan 12, 2025
@nour0205
Copy link

nour0205 commented Jan 26, 2025

Bug confirmation : Timeline Text Overflow Issue

Hi @0xshellming
Thank you for reporting this issue! I've thoroughly investigated it and can confirm that the bug exists. Below are the detailed steps i followed, along with additional observations and environment details

Steps to Reproduce
1. Opened the Mermaid Live Editor.
2. Used the following code snippet:

	`	
	timeline
	    title Evolution of Programming Languages
	    1950 : Assembly
	    1970 : LongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLong
	    1980 : C
	         : Smalltalk (Object-Oriented Programming introduced)
	    1991 : Python (Readable, Versatile, Popular in AI and Data Science)
	    1995 : JavaScript (Web Revolution LongLongLongLongLongLongLong)
	         : Java (Write Once, Run Anywhere)
	    2000 : LongTextLongTextLongTextLongTextLongTextLongTextLongTextLongTextLongText
	    2010 : Kotlin (Android Development) and Swift (iOS Development)
	    2020 : WebAssembly (New Era for Browsers)`
  1. Rendered the timeline chart.
  2. Observed the issue: Long text overflows outside the color block, making it hard to read and visually unaligned.

Here is a screenshot of the issue as observed in my testing:

Image

I also tested the timeline in the demo

Image

Key Observations
• The text for the entry "JavaScript (Web Revolution LongLongLongLongLongLong)" overflows the block, which disrupts the layout and alignment of the timeline.

• In the first example the entries for 1991 and 2010 experience inconsistent text overflow issues, with the text for 1991 spilling above the block and for 2010 underfilling the block

Environment Details
• Mermaid Version: 0.2.4
• Browsers Tested:
Mozilla Firefox (Version: 134.0.2)
Microsoft Edge (Version: 132.0.2957.115)
• Operating System: (Windows 11)

Additional Observations
• The bug occurs consistently across all tested browsers.
• The issue is more noticeable with extremely long text entries.
• Shorter text entries do not exhibit this problem.
• Multiple timeline entries for the same year are unaffected unless the text is long.

Thank you for reporting this issue! I hope the additional details provided here help the maintainers reproduce and categorize it further. Let me know if any other information or testing is required!

@nour0205
Copy link

nour0205 commented Feb 6, 2025

Hi @0xshellming

I've investigated and fixed the issue where Timeline Diagram text did not automatically wrap when the text is too long.

Fix Summary:

Updated the wrap function in svgDrawer.js to handle long text properly.
Ensured long words are split into smaller chunks to prevent overflow.

Results:
Long text wraps within nodes, ensuring no overflow or misalignment.
The background adjusts dynamically to the text size.
The timeline remains visually consistent and readable.

Modified Files:
packages/mermaid/src/diagrams/timeline/svgDrawer.js – Improved text wrapping logic for timeline diagrams.

Resulting Fix:

Here’s the updated Timeline Diagram after applying the fix:

Image

Mermaid Version: 11.4.1

I have submitted a PR to address this: #6258.
Please review it when you get the chance!

Let me know if you have any feedback or suggestions.

Thanks! 😊

@0xshellming
Copy link
Author

Hi @0xshellming

I've investigated and fixed the issue where Timeline Diagram text did not automatically wrap when the text is too long.

Fix Summary:

Updated the wrap function in svgDrawer.js to handle long text properly. Ensured long words are split into smaller chunks to prevent overflow.

Results: Long text wraps within nodes, ensuring no overflow or misalignment. The background adjusts dynamically to the text size. The timeline remains visually consistent and readable.

Modified Files: packages/mermaid/src/diagrams/timeline/svgDrawer.js – Improved text wrapping logic for timeline diagrams.

Resulting Fix:

Here’s the updated Timeline Diagram after applying the fix:

Image

Mermaid Version: 11.4.1

I have submitted a PR to address this: #6258. Please review it when you get the chance!

Let me know if you have any feedback or suggestions.

Thanks! 😊

Great! thank you for solving this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
2 participants