Skip to content

feat(wardley): opt-in automatic label placement (autoPlaceLabels)#7767

Open
tractorjuice wants to merge 5 commits into
mermaid-js:developfrom
tractorjuice:feat/wardley-autoplace-labels
Open

feat(wardley): opt-in automatic label placement (autoPlaceLabels)#7767
tractorjuice wants to merge 5 commits into
mermaid-js:developfrom
tractorjuice:feat/wardley-autoplace-labels

Conversation

@tractorjuice
Copy link
Copy Markdown
Contributor

@tractorjuice tractorjuice commented May 21, 2026

Summary

Adds an opt-in autoPlaceLabels config flag to the wardley-beta diagram — off by default, so existing maps render unchanged.

When enabled, component, anchor, link and annotation labels are repositioned to avoid overlapping each other, node markers, pipeline boxes, the chart boundary and link lines:

  • Labels moved far from their node get a thin leader line.
  • A collision-free manual label [x, y] is kept exactly as authored; a colliding one is re-placed but biased toward the authored position.
  • Pipeline child components prefer their label underneath.
  • The algorithm is a new pure, deterministic, unit-tested module (wardleyLabelPlacement.ts). The renderer path is unchanged when the flag is off.

Enable via config:

mermaid.initialize({ 'wardley-beta': { autoPlaceLabels: true } });

⚠️ Stacked on #7696

This is built on top of #7696 (wardley (ecosystem) decorator + attitude zones). Until #7696 merges, the diff here also shows #7696's commits — please review #7696 first. The net-new change in this PR is the autoplacement work, 8 files: wardleyLabelPlacement.ts + .spec.ts, wardleyRenderer.ts, styles.ts, config.schema.yaml, config.type.ts, the Cypress wardley spec, and a changeset. I'll rebase onto develop once #7696 merges.

Test Plan

  • 73 wardley unit tests pass (packages/mermaid/src/diagrams/wardley).
  • tsc --noEmit is clean.
  • New Cypress visual tests in cypress/integration/rendering/wardley/wardley.spec.js: dense map, kept vs re-placed manual labels, pipeline-child placement.
  • Spot-checked by rendering real-world Wardley maps with the flag on and off.

🤖 Generated with Claude Code

tractorjuice and others added 3 commits April 29, 2026 21:34
- Add `(ecosystem)` source-strategy alongside build/buy/outsource/market.
  Renders as concentric circles with a diagonal-hatch ring, matching the
  OWM ecosystem-play symbol.
- Add attitude zones using OWM's canonical 4-coordinate form
  `keyword [v1, m1, v2, m2]`. Renders as a translucent labelled rectangle
  in OWM's colour palette: pioneers (light blue), settlers (medium blue),
  townplanners (purple).
- Accept `explorers` as an alias for `pioneers` and `villagers` as an
  alias for `settlers`.
- Update Sourcing Strategy docs (corrected misleading shape descriptions
  for build/buy/outsource/market) and add an Attitude Zones section with
  example.
- Refresh tool URL to create.wardleymaps.ai and drop dead link.

Tests: 45 unit tests (parser package + mermaid package + builder),
plus Cypress fixtures for both new features.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…s, docs

- Wire pioneers/settlers/townplanners stroke+fill and ecosystem
  outer/middle/inner fills through `themeVariables.wardley?.X` with
  OWM hex defaults, matching the existing wardley theming pattern.
- Restore learnwardleymapping.com link to Resources alongside
  create.wardleymaps.ai.
- Use "evolution" consistently instead of "maturity" in docs.
- Clamp attitude zone label Y so it can't fall outside very thin
  rectangles.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented May 21, 2026

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 57797f9
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/6a0f0d2dde94cc000835603e
😎 Deploy Preview https://deploy-preview-7767--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.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 21, 2026

🦋 Changeset detected

Latest commit: 57797f9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
mermaid Minor

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

@github-actions github-actions Bot added the Type: Enhancement New feature or request label May 21, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 21, 2026

Open in StackBlitz

@mermaid-js/examples

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

mermaid

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

@mermaid-js/layout-elk

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

@mermaid-js/layout-tidy-tree

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

@mermaid-js/mermaid-zenuml

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

@mermaid-js/parser

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

@mermaid-js/tiny

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

commit: 57797f9

@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

❌ Patch coverage is 0.13175% with 758 lines in your changes missing coverage. Please review.
✅ Project coverage is 3.22%. Comparing base (92dc556) to head (57797f9).
⚠️ Report is 266 commits behind head on develop.

Files with missing lines Patch % Lines
...es/mermaid/src/diagrams/wardley/wardleyRenderer.ts 0.00% 394 Missing ⚠️
...maid/src/diagrams/wardley/wardleyLabelPlacement.ts 0.30% 326 Missing ⚠️
...ages/mermaid/src/diagrams/wardley/wardleyParser.ts 0.00% 17 Missing ⚠️
packages/parser/tests/test-util.ts 0.00% 9 Missing ⚠️
...ges/mermaid/src/diagrams/wardley/wardleyBuilder.ts 0.00% 6 Missing ⚠️
packages/mermaid/src/diagrams/wardley/wardleyDb.ts 0.00% 5 Missing ⚠️
packages/mermaid/src/diagrams/wardley/styles.ts 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #7767      +/-   ##
==========================================
- Coverage     3.33%   3.22%   -0.12%     
==========================================
  Files          542     600      +58     
  Lines        56881   61564    +4683     
  Branches       839     918      +79     
==========================================
+ Hits          1899    1987      +88     
- Misses       54982   59577    +4595     
Flag Coverage Δ
unit 3.22% <0.13%> (-0.12%) ⬇️

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/wardley/styles.ts 2.85% <0.00%> (-0.09%) ⬇️
packages/mermaid/src/diagrams/wardley/wardleyDb.ts 0.00% <0.00%> (ø)
...ges/mermaid/src/diagrams/wardley/wardleyBuilder.ts 0.81% <0.00%> (-0.05%) ⬇️
packages/parser/tests/test-util.ts 1.08% <0.00%> (-0.12%) ⬇️
...ages/mermaid/src/diagrams/wardley/wardleyParser.ts 0.50% <0.00%> (-0.05%) ⬇️
...maid/src/diagrams/wardley/wardleyLabelPlacement.ts 0.30% <0.30%> (ø)
...es/mermaid/src/diagrams/wardley/wardleyRenderer.ts 0.08% <0.00%> (-0.04%) ⬇️

... and 107 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.

Adds an opt-in `autoPlaceLabels` config flag to the wardley-beta diagram.
When enabled, component/anchor/link/annotation labels are repositioned to
avoid overlapping each other, node markers, pipeline boxes, the chart
boundary and link lines, with leader lines for far-placed labels. A
collision-free manual `label [x, y]` is kept as authored; pipeline child
labels prefer placement underneath. Placement is a pure, deterministic,
unit-tested module (wardleyLabelPlacement.ts); the renderer path is
unchanged when the flag is off.

Stacked on mermaid-js#7696 (wardley ecosystem/attitudes).
@tractorjuice tractorjuice force-pushed the feat/wardley-autoplace-labels branch from bf9ba61 to 49b8d57 Compare May 21, 2026 13:32
@tractorjuice tractorjuice changed the title feat(wardley): automatic label placement, ecosystem source strategy, and attitude zones feat(wardley): opt-in automatic label placement (autoPlaceLabels) May 21, 2026
@argos-ci
Copy link
Copy Markdown

argos-ci Bot commented May 21, 2026

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

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 5 added May 21, 2026, 2:07 PM

Reword a doc comment to drop a word cspell does not know, and collapse a
lonely nested if into its else-if condition (unicorn/no-lonely-if).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant