mermaid-js / mermaid

Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown
https://mermaid.js.org
MIT License
68.63k stars 6.05k forks source link

[XYChart] incorrect spacing between data points #5555

Closed OG-NI closed 1 week ago

OG-NI commented 4 weeks ago

Description

When using the XYChart in combination with a numeric range for the x-axis, the distance between the individual data points is not always correct. This leads to the data being distorted in an unpredictable way and data points on the right hand side of the diagram to be cut off.

Steps to reproduce

Copy the code sample below or create a XYChart with a numeric range where $\text{max} - \text{min} + 1 \ne \text{number of data points}$.

Screenshots

screenshot

Code Sample

xychart-beta
    x-axis 0 --> 2
    line [0, 1, 0, 1]
    bar [1, 0, 1, 0]

Setup

Suggested Solutions

Change const step = (max - min + 1) / data.length; in xychartDb.ts to const step = (max - min) / (data.length - 1);.

Additional Context

No response