Skip to content

XY Chart bar chart doesn't begin at zero #6517

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

Open
olli4 opened this issue Apr 22, 2025 · 1 comment · May be fixed by #6526
Open

XY Chart bar chart doesn't begin at zero #6517

olli4 opened this issue Apr 22, 2025 · 1 comment · May be fixed by #6526
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@olli4
Copy link

olli4 commented Apr 22, 2025

Description

XY Chart bar chart bars do not begin at zero. They begin at the x axis line that is not at y zero value even when the y axis lower limit is set to 0. This is visually misleading when comparing heights of charts, especially when a bar is very short and the added extra height is large proportionally. Bars would be expected to begin at zero.

Steps to reproduce

I have included a code sample to reproduce.

Screenshots

Current result from the code sample:

Image

What it should look like (emulated by adding bar [0, 0, 0, 0, 0, 0] at the end of the code sample) :

Image

Code Sample

---
config:
    xyChart:
        width: 900
        height: 600
    themeVariables:
        xyChart:
            backgroundColor: "#000"
            titleColor: "#fff"
            xAxisLabelColor: "#fff"
            xAxisTitleColor: "#fff"
            xAxisTickColor: "#fff"
            xAxisLineColor: "#fff"
            yAxisLabelColor: "#fff"
            yAxisTitleColor: "#fff"
            yAxisTickColor: "#fff"
            yAxisLineColor: "#fff"
            plotColorPalette: "#888, #000"
---
xychart-beta
    title "Sentinel 2 L1C patch time series — HAMK GPU server"
    x-axis ["Allas S3 SAFE", "Allas S3 COG", "Allas S3 Zarr", "/data SAFE", "/data COG", "/data Zarr"]
    y-axis "Mean load time (s)" 0 --> 200
    bar [8302, 191, 21.7, 99.2, 34.8, 1.77]

Setup

  • Mermaid version: 11.6.0
  • Browser and Version: Markdown Preview Mermaid Support, Chrome Version 135.0.7049.96 (Official Build) (64-bit)

Suggested Solutions

The bars should begin at y value zero. If y value zero is below the x axis line (true when y lower limit is high enough) then the bar should be clipped at the x axis line.

Additional Context

No response

@olli4 olli4 added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Apr 22, 2025
@duyaan
Copy link

duyaan commented Apr 22, 2025

Hi @olli4 ;

I have noticed the same problem and I am currently working on fix it .
I will post a PR right after fixing the issue .

Thank you .

duyaan added a commit to duyaan/mermaid that referenced this issue Apr 23, 2025
@duyaan duyaan linked a pull request Apr 23, 2025 that will close this issue
4 tasks
duyaan added a commit to duyaan/mermaid that referenced this issue Apr 25, 2025
…ng other charts

- Added optional  field to XYChartAxisConfig.
- Modified LinearAxis to conditionally include 0 in the domain if  is true.
- Only bar charts set , ensuring Y-axis starts from 0.
- Other charts (line, area, etc.) remain dynamically scaled without forcing 0.
- Fixes issue mermaid-js#6517.
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
Development

Successfully merging a pull request may close this issue.

2 participants