diff --git a/cypress/integration/rendering/xyChart.spec.js b/cypress/integration/rendering/xyChart.spec.js index 85d998c50..49e435ba2 100644 --- a/cypress/integration/rendering/xyChart.spec.js +++ b/cypress/integration/rendering/xyChart.spec.js @@ -319,4 +319,16 @@ describe('XY Chart', () => { ); cy.get('svg'); }); + it('should use the correct distances between data points', () => { + imgSnapshotTest( + ` + xychart-beta + x-axis 0 --> 2 + line [0, 1, 0, 1] + bar [1, 0, 1, 0] + `, + {} + ); + cy.get('svg'); + }); }); diff --git a/packages/mermaid/src/diagrams/xychart/xychartDb.ts b/packages/mermaid/src/diagrams/xychart/xychartDb.ts index 637477f28..23b90724c 100644 --- a/packages/mermaid/src/diagrams/xychart/xychartDb.ts +++ b/packages/mermaid/src/diagrams/xychart/xychartDb.ts @@ -143,7 +143,7 @@ function transformDataWithoutCategory(data: number[]): SimplePlotDataType { if (isLinearAxisData(xyChartData.xAxis)) { const min = xyChartData.xAxis.min; const max = xyChartData.xAxis.max; - const step = (max - min + 1) / data.length; + const step = (max - min) / (data.length - 1); const categories: string[] = []; for (let i = min; i <= max; i += step) { categories.push(`${i}`);