Skip to content

Commit

Permalink
Merge pull request #5556 from OG-NI/bug/5555_xychart_incorrect_spacing
Browse files Browse the repository at this point in the history
[XYChart] fixed incorrect spacing between data points
  • Loading branch information
sidharthv96 authored Jun 21, 2024
2 parents 1e43ad1 + 0c49d2b commit 9f37513
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions cypress/integration/rendering/xyChart.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,16 @@ describe('XY Chart', () => {
{}
);
});
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');
});
});
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/xychart/xychartDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down

0 comments on commit 9f37513

Please sign in to comment.