Skip to content

feat(gantt): support configurable workday hours for hour durations#7733

Open
puneetdixit200 wants to merge 4 commits into
mermaid-js:developfrom
puneetdixit200:fix/4060-working-day-hours
Open

feat(gantt): support configurable workday hours for hour durations#7733
puneetdixit200 wants to merge 4 commits into
mermaid-js:developfrom
puneetdixit200:fix/4060-working-day-hours

Conversation

@puneetdixit200
Copy link
Copy Markdown

@puneetdixit200 puneetdixit200 commented May 9, 2026

Summary

Closes #4060

Adds configurable workday hours for Gantt diagrams so hour-based task durations can represent non-24-hour workdays.

Changes

  • Added a workdayhours Gantt directive, for example workdayhours 8
  • Applied workdayhours when parsing task durations that use h
  • Kept the default behavior as 24 hours per day
  • Added parser and Gantt DB test coverage
  • Updated Gantt docs and config schema/type definitions

Example

gantt
  dateFormat YYYY-MM-DD
  workdayhours 8
  section Example
  Task A :a1, 2024-01-01, 20h
Loading

Testing

  • corepack pnpm exec prettier --check docs/syntax/gantt.md packages/mermaid/src/config.type.ts packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts
  • corepack pnpm exec eslint --quiet --stats --cache --cache-strategy content packages/mermaid/src/config.type.ts packages/mermaid/src/diagrams/gantt/ganttDb.js
  • corepack pnpm exec cspell docs/syntax/gantt.md packages/mermaid/src/config.type.ts packages/mermaid/src/diagrams/gantt/ganttDb.js
  • corepack pnpm exec vitest run packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js

Copilot AI review requested due to automatic review settings May 9, 2026 15:27
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 9, 2026

🦋 Changeset detected

Latest 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

@netlify
Copy link
Copy Markdown

netlify Bot commented May 9, 2026

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 4bf6584
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/6a0996859bff0300088ea9bd
😎 Deploy Preview https://deploy-preview-7733--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the Type: Bug / Error Something isn't working or is incorrect label May 9, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 9, 2026

Open in StackBlitz

@mermaid-js/examples

npm i https://pkg.pr.new/@mermaid-js/examples@7733

mermaid

npm i https://pkg.pr.new/mermaid@7733

@mermaid-js/layout-elk

npm i https://pkg.pr.new/@mermaid-js/layout-elk@7733

@mermaid-js/layout-tidy-tree

npm i https://pkg.pr.new/@mermaid-js/layout-tidy-tree@7733

@mermaid-js/mermaid-zenuml

npm i https://pkg.pr.new/@mermaid-js/mermaid-zenuml@7733

@mermaid-js/parser

npm i https://pkg.pr.new/@mermaid-js/parser@7733

@mermaid-js/tiny

npm i https://pkg.pr.new/@mermaid-js/tiny@7733

commit: 4bf6584

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 workdayhours directive in the Gantt grammar/parser and wires it into the Gantt DB.
  • Adjusts hour-duration end-date calculation to scale h durations 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.

Comment on lines +209 to +219
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
Copy link
Copy Markdown

codecov Bot commented May 9, 2026

Codecov Report

❌ Patch coverage is 90.90909% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 3.33%. Comparing base (f50fb4f) to head (4bf6584).
⚠️ Report is 114 commits behind head on develop.

Files with missing lines Patch % Lines
packages/mermaid/src/diagrams/gantt/ganttDb.js 90.90% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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     
Flag Coverage Δ
unit 3.33% <90.90%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/mermaid/src/config.type.ts 100.00% <ø> (ø)
packages/mermaid/src/diagrams/gantt/ganttDb.js 77.57% <90.90%> (+0.59%) ⬆️

... and 62 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@argos-ci
Copy link
Copy Markdown

argos-ci Bot commented May 9, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - May 17, 2026, 10:34 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug / Error Something isn't working or is incorrect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configure Gantt diagram to use specific day hours

2 participants