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

#5858 - fix: Timeline node width made dynamic #6100

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

afmireski
Copy link

📑 Summary

In timelineRenderer, the width of the timeline diagram nodes is hardcoded, making width configuration changes ineffective.

Resolves #5858

📏 Design Decisions

Extract the hardcoded value, defined here, into a constant and use it as the default if the node width is not specified in the timeline configuration.
I've added tests to verify the application of both the default and custom widths.

📋 Tasks

Make sure you

  • 📖 have read the contribution guidelines
  • 💻 have added necessary unit/e2e tests.
  • 📓 have added documentation. Make sure MERMAID_RELEASE_VERSION is used for all new features.
  • 🦋 If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

- Refactored timelineRenderer.drawEvents
    - Added DEFAULT_NODE_WIDTH of 150
    - Used conf?.timeline?.width as a dynamic value, or default value if
not provided
- Added integration tests in
cypress/integration/rendering/timeline.spec.ts to cover changes
@github-actions github-actions bot added the Type: Bug / Error Something isn't working or is incorrect label Nov 30, 2024
Copy link

netlify bot commented Nov 30, 2024

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit b264dbc
🔍 Latest deploy log https://app.netlify.com/sites/mermaid-js/deploys/679fc5de06d5dc0008ed147a
😎 Deploy Preview https://deploy-preview-6100--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

pkg-pr-new bot commented Nov 30, 2024

Open in Stackblitz

npm i https://pkg.pr.new/mermaid-js/mermaid@6100
npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-elk@6100
npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/mermaid-zenuml@6100
npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/parser@6100

commit: b264dbc

Copy link

codecov bot commented Nov 30, 2024

Codecov Report

Attention: Patch coverage is 0% with 24 lines in your changes missing coverage. Please review.

Project coverage is 4.47%. Comparing base (cc29437) to head (b264dbc).
Report is 132 commits behind head on develop.

Files with missing lines Patch % Lines
.../mermaid/src/diagrams/timeline/timelineRenderer.ts 0.00% 24 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #6100      +/-   ##
==========================================
- Coverage     4.49%   4.47%   -0.03%     
==========================================
  Files          383     384       +1     
  Lines        53925   54194     +269     
  Branches       596     623      +27     
==========================================
  Hits          2425    2425              
- Misses       51500   51769     +269     
Flag Coverage Δ
unit 4.47% <0.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
.../mermaid/src/diagrams/timeline/timelineRenderer.ts 0.00% <0.00%> (ø)

... and 22 files with indirect coverage changes

@afmireski
Copy link
Author

Hello,

Looking at the test workflow failures, I noticed that the tests passed:
image

The error seems to be related to insufficient storage for saving Cypress screenshots:
image

Is there any correction I need to make?

I also noticed that Codecov reported a lack of coverage, but my integration tests appear to be running correctly. I would greatly appreciate any suggestions or feedback you can provide. I'm a newbie in open-source.

@afmireski
Copy link
Author

Hi @jgreywolf, I hope you're doing well! When you have some time, could you kindly take a look at my PR? Let me know if anything needs adjustment. Thanks!

Copy link

@chriscconte chriscconte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, I believe this is almost there, but as is, it's not functioning as intended. Below is the screenshot of a current simple test:

image source

In order to fix this, we will need to also adjust the section and task width alongside the event width. It's all configured in the same file.

I've done an implementation here, but since you've already PR'd feel free to adapt/grab what I've done.

Nit: I think that we should consider re-naming this config property to taskWidth or eventWidth, in order to increase readability. And update the timelineConfig page to reflect that, and potentially remove all of the non-functional config variables.

- Added const DEFAULT_TASK_WIDTH of 150
- Refactored timelineRendered.draw
 - Added taskWidth, that used conf?.timeline?.width as dynamic value or
default value if not provided
- Refactored timelineRendered.drawTasks
 - Added taskWidth, that used conf?.timeline?.width as dynamic value or
default value if not provided
- Renamed nodeWidth variable in drawEvents to eventNodeWidth

Thanks to @chriscconte for the helpful suggestions
Copy link

changeset-bot bot commented Feb 2, 2025

⚠️ No Changeset found

Latest commit: b264dbc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@afmireski
Copy link
Author

Thanks for your feedback, @chriscconte ! I’ve applied your suggestions, and the timeline rendering looks much better now.
image

Copy link

@chriscconte chriscconte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timeline does not honor width configuration
2 participants