Skip to content

Conversation

@ia319
Copy link

@ia319 ia319 commented Oct 16, 2025

📑 Summary

Add isBandAxis property to BaseAxis and refine axis padding logic to handle both vertical and horizontal charts:

  • Distinguish axis types using isBandAxis
  • Apply padding on both ends for band (categorical) axes
  • Align start of linear axes with other axis and apply padding at the end

Resolves #7061

📏 Design Decisions

Problem: Previous getRange() logic only considered axis position, applied padding for both ends, causing misalignment in vertical and horizontal charts.

Fix:

  • Introduce isBandAxis to identify band (categorical) axes

  • Apply padding differently based on axis type and orientation:

    • Band axes: padding on both ends
    • Linear axes: align start with other axis, padding only on the end

Effect:

  • Zero tick for vertical axes aligns at chart bottom
  • Horizontal axes and existing behavior remain unaffected

📋 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:.

add condition to handle vertical axes ('left' or 'right')
ensure:
- top padding remain for visual spacing
- bottom padding remove to align zero tick with chart base
@changeset-bot
Copy link

changeset-bot bot commented Oct 16, 2025

⚠️ No Changeset found

Latest commit: 4bc2db3

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

@netlify
Copy link

netlify bot commented Oct 16, 2025

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 4bc2db3
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/68f4a0589dc727000847aa59
😎 Deploy Preview https://deploy-preview-7083--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 project configuration.

@github-actions github-actions bot added the Type: Bug / Error Something isn't working or is incorrect label Oct 16, 2025
@ia319 ia319 changed the title fix(xychart): fix y-axis tick positioning (#7061) fix(baseAxis): fix y-axis tick positioning (#7061) Oct 16, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 16, 2025

Open in StackBlitz

@mermaid-js/examples

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/examples@7083

mermaid

npm i https://pkg.pr.new/mermaid-js/mermaid@7083

@mermaid-js/layout-elk

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-elk@7083

@mermaid-js/layout-tidy-tree

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-tidy-tree@7083

@mermaid-js/mermaid-zenuml

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/mermaid-zenuml@7083

@mermaid-js/parser

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/parser@7083

@mermaid-js/tiny

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/tiny@7083

commit: 4bc2db3

@codecov
Copy link

codecov bot commented Oct 16, 2025

Codecov Report

❌ Patch coverage is 0% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 3.55%. Comparing base (3d768f3) to head (4bc2db3).

Files with missing lines Patch % Lines
...ms/xychart/chartBuilder/components/plot/barPlot.ts 0.00% 17 Missing ⚠️
...s/xychart/chartBuilder/components/axis/baseAxis.ts 0.00% 8 Missing ⚠️
...s/xychart/chartBuilder/components/axis/bandAxis.ts 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #7083      +/-   ##
==========================================
- Coverage     3.55%   3.55%   -0.01%     
==========================================
  Files          473     474       +1     
  Lines        47481   47513      +32     
  Branches       730     730              
==========================================
  Hits          1687    1687              
- Misses       45794   45826      +32     
Flag Coverage Δ
unit 3.55% <0.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
...rams/xychart/chartBuilder/components/axis/index.ts 3.84% <ø> (ø)
...s/xychart/chartBuilder/components/axis/bandAxis.ts 2.94% <0.00%> (-0.09%) ⬇️
...s/xychart/chartBuilder/components/axis/baseAxis.ts 0.26% <0.00%> (-0.01%) ⬇️
...ms/xychart/chartBuilder/components/plot/barPlot.ts 1.61% <0.00%> (-0.43%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@argos-ci
Copy link

argos-ci bot commented Oct 16, 2025

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 33 changed Oct 19, 2025, 8:36 AM

ia319 and others added 4 commits October 16, 2025 17:45
…l charts

add isBandAxis property to BaseAxis to distinguish axis types and apply padding correctly for different axes
- add isBandAxis property to BaseAxis to distinguish axis types
- apply padding on both ends for band (categorical) axes
- align start of linear axes with other axis and apply padding at the end
…ype adaptation

fix first bar overflow when bottom axis is value axis.

check if x-axis is category axis:
- if yes, apply original width logic
- if no, set barWidthHalf = 0 and adjust total width to fit extra half bar
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.

The 0 in y-axis of an XY Chart is marked higher than it should be

1 participant