mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-14 01:34:19 +01:00
fix:gant chart crashing in browser
on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
This commit is contained in:
@@ -803,4 +803,34 @@ describe('Gantt diagram', () => {
|
|||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it('should handle numeric timestamps with dateFormat x', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
gantt
|
||||||
|
title Process time profile (ms)
|
||||||
|
dateFormat x
|
||||||
|
axisFormat %L
|
||||||
|
tickInterval 250millisecond
|
||||||
|
|
||||||
|
section Pipeline
|
||||||
|
Parse JSON p1: 000, 120
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('should handle numeric timestamps with dateFormat X', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
gantt
|
||||||
|
title Process time profile (ms)
|
||||||
|
dateFormat X
|
||||||
|
axisFormat %L
|
||||||
|
tickInterval 250millisecond
|
||||||
|
|
||||||
|
section Pipeline
|
||||||
|
Parse JSON p1: 000, 120
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -268,7 +268,9 @@ const fixTaskDates = function (startTime, endTime, dateFormat, excludes, include
|
|||||||
|
|
||||||
const getStartDate = function (prevTime, dateFormat, str) {
|
const getStartDate = function (prevTime, dateFormat, str) {
|
||||||
str = str.trim();
|
str = str.trim();
|
||||||
|
if ((dateFormat.trim() === 'x' || dateFormat.trim() === 'X') && /^\d+$/.test(str)) {
|
||||||
|
return new Date(Number(str));
|
||||||
|
}
|
||||||
// Test for after
|
// Test for after
|
||||||
const afterRePattern = /^after\s+(?<ids>[\d\w- ]+)/;
|
const afterRePattern = /^after\s+(?<ids>[\d\w- ]+)/;
|
||||||
const afterStatement = afterRePattern.exec(str);
|
const afterStatement = afterRePattern.exec(str);
|
||||||
|
|||||||
Reference in New Issue
Block a user