diff --git a/.changeset/moody-fans-try.md b/.changeset/moody-fans-try.md new file mode 100644 index 000000000..f6920a629 --- /dev/null +++ b/.changeset/moody-fans-try.md @@ -0,0 +1,5 @@ +--- +'mermaid': patch +--- + +fix: Resolve gantt chart crash due to invalid array length diff --git a/.github/workflows/e2e-timings.yml b/.github/workflows/e2e-timings.yml index 21dbda293..635253bc8 100644 --- a/.github/workflows/e2e-timings.yml +++ b/.github/workflows/e2e-timings.yml @@ -58,7 +58,7 @@ jobs: echo "EOF" >> $GITHUB_OUTPUT - name: Commit and create pull request - uses: peter-evans/create-pull-request@18e469570b1cf0dfc11d60ec121099f8ff3e617a + uses: peter-evans/create-pull-request@915d841dae6a4f191bb78faf61a257411d7be4d2 with: add-paths: | cypress/timings.json diff --git a/cypress/integration/rendering/gantt.spec.js b/cypress/integration/rendering/gantt.spec.js index 32dbcb4d9..72cb6ea29 100644 --- a/cypress/integration/rendering/gantt.spec.js +++ b/cypress/integration/rendering/gantt.spec.js @@ -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 + `, + {} + ); + }); }); diff --git a/packages/examples/package.json b/packages/examples/package.json index cd0fc0bd0..10f66c2b9 100644 --- a/packages/examples/package.json +++ b/packages/examples/package.json @@ -3,6 +3,7 @@ "version": "1.0.0", "description": "Mermaid examples package", "author": "Sidharth Vinod", + "license": "MIT", "type": "module", "module": "./dist/mermaid-examples.core.mjs", "types": "./dist/mermaid.d.ts", diff --git a/packages/mermaid/src/diagrams/gantt/ganttDb.js b/packages/mermaid/src/diagrams/gantt/ganttDb.js index b2b5b0566..b1b2052c1 100644 --- a/packages/mermaid/src/diagrams/gantt/ganttDb.js +++ b/packages/mermaid/src/diagrams/gantt/ganttDb.js @@ -268,7 +268,9 @@ const fixTaskDates = function (startTime, endTime, dateFormat, excludes, include const getStartDate = function (prevTime, dateFormat, str) { str = str.trim(); - + if ((dateFormat.trim() === 'x' || dateFormat.trim() === 'X') && /^\d+$/.test(str)) { + return new Date(Number(str)); + } // Test for after const afterRePattern = /^after\s+(?[\d\w- ]+)/; const afterStatement = afterRePattern.exec(str);