feat(gantt): support configurable workday hours for hour durations#7733
feat(gantt): support configurable workday hours for hour durations#7733puneetdixit200 wants to merge 4 commits into
Conversation
🦋 Changeset detectedLatest commit: 4bf6584 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for mermaid-js ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
@mermaid-js/examples
mermaid
@mermaid-js/layout-elk
@mermaid-js/layout-tidy-tree
@mermaid-js/mermaid-zenuml
@mermaid-js/parser
@mermaid-js/tiny
commit: |
There was a problem hiding this comment.
Pull request overview
Adds a new Gantt directive/config option to interpret hour-based durations (h) using a configurable “workday hours” length, enabling hour durations to represent non-24-hour business days (closes #4060).
Changes:
- Introduces
workdayhoursdirective in the Gantt grammar/parser and wires it into the Gantt DB. - Adjusts hour-duration end-date calculation to scale
hdurations based on configured workday hours (default remains 24). - Updates config schema/types, docs, and adds parser + DB tests.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/mermaid/src/schemas/config.schema.yaml | Adds gantt.workdayhours to the JSON schema with validation and default. |
| packages/mermaid/src/docs/syntax/gantt.md | Documents the new workdayhours directive and config option usage. |
| packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js | Adds parser test coverage for the workdayhours directive. |
| packages/mermaid/src/diagrams/gantt/parser/gantt.jison | Extends lexer/grammar to parse workdayhours and call into the DB. |
| packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts | Adds DB-level test ensuring h durations scale with workday hours. |
| packages/mermaid/src/diagrams/gantt/ganttDb.js | Implements workday-hours storage + applies scaling for h duration parsing. |
| packages/mermaid/src/config.type.ts | Adds workdayhours?: number to GanttDiagramConfig typing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export const setWorkdayHours = function (hours) { | ||
| if (Number.isFinite(hours) && hours > 0) { | ||
| workdayHours = hours; | ||
| } | ||
| }; | ||
|
|
||
| export const getWorkdayHours = function () { | ||
| const configuredHours = getConfig()?.workdayhours; | ||
| if (Number.isFinite(configuredHours) && configuredHours > 0) { | ||
| return configuredHours; | ||
| } |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #7733 +/- ##
==========================================
+ Coverage 3.29% 3.33% +0.04%
==========================================
Files 561 600 +39
Lines 58576 60679 +2103
Branches 873 933 +60
==========================================
+ Hits 1928 2024 +96
- Misses 56648 58655 +2007
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
Summary
Closes #4060
Adds configurable workday hours for Gantt diagrams so hour-based task durations can represent non-24-hour workdays.
Changes
workdayhoursGantt directive, for exampleworkdayhours 8workdayhourswhen parsing task durations that usehExample
Testing
corepack pnpm exec prettier --check docs/syntax/gantt.md packages/mermaid/src/config.type.ts packages/mermaid/src/diagrams/gantt/ganttDb.spec.tscorepack pnpm exec eslint --quiet --stats --cache --cache-strategy content packages/mermaid/src/config.type.ts packages/mermaid/src/diagrams/gantt/ganttDb.jscorepack pnpm exec cspell docs/syntax/gantt.md packages/mermaid/src/config.type.ts packages/mermaid/src/diagrams/gantt/ganttDb.jscorepack pnpm exec vitest run packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js