Skip to content

Write a collapsible Gantt chart as SVG - #405

Merged
Paebbels merged 3 commits into
devfrom
claude/tracing-collapsible-svg
Sep 27, 2026
Merged

Paebbels merged 3 commits into
devfrom
claude/tracing-collapsible-svg

Conversation

@pytooling-claude

@pytooling-claude pytooling-claude Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Note

Ported onto dev. #404 merged as a renderer class (GanttLayout + Renderer + MatplotlibRenderer), so this pull-request no longer extends the function WriteGantt: the options are MatplotlibRenderer's, and the script is added in its _Write. The branch now holds this one commit on top of dev; behaviour, script and testcases are those of the first version.

A pipeline chart with steps has far too many rows to read - GHDL's master pipeline has 1575 rows when only skipped steps are hidden - and one without steps hides where a job spent its time. This pull-request makes a Gantt chart written as SVG collapsible: a click on a called workflow or a job hides or shows the rows below it, so the chart opens compact and a job's steps are one click away.

New Features

  • pyTooling.Tracing.Render.Matplotlib.MatplotlibRenderer
    • MatplotlibRenderer(layout, collapsible=True) adds a script to an SVG file. A click on the label, bar or line of a row with sub-rows hides every row below it and moves the following rows up; a second click shows them again. A marker in front of the label shows the state, ▸ collapsed or ▾ expanded.
    • collapsedKinds - default: jobs - names the CI span kinds whose rows start collapsed. With ciSpanFilter(excludeSteps=StepExclusion.Skipped) the chart opens with the jobs' steps hidden, and a click on a job expands them.
    • Both are read-only properties: Collapsible and CollapsedKinds.
    • The script knows every shown row's identifier, its parent among the shown rows and whether it starts collapsed, plus the distance between two rows in the SVG file's coordinates - converted from matplotlib's display coordinates at 72 units per inch.
    • Write of a collapsible renderer to a PNG or PDF file raises a ValueError, before anything is drawn.
    • The script and its stylesheet are resource files, CollapsibleGantt.js and CollapsibleGantt.css in the new
      resource package pyTooling.Resources.Tracing. Their content is embedded, so the SVG file stays self-contained;
      getResourceFile returns their paths. setup.py ships them.
  • Render gives every row's label the identifier label-<SpanID>, next to the bars' span-<SpanID>. A collapsible chart draws no tick marks on the y axis, which would stay behind when rows move.

Documentation

  • doc/Tracing.rst gains a section Collapsible SVG: how to write one, which rows start collapsed, and where the script runs - in a browser, or embedded by <object> or inline; an SVG shown as an image (<img>, Markdown, a job summary) stays static.
  • doc/News.rst lists the collapsible SVG.

Unit Tests

  • Four new testcases in tests/unit/Tracing/Render.py:
    • every row's label carries its identifier, and a file that isn't collapsible has no script;
    • a collapsible file is still well-formed XML, its data names the parents and the rows starting collapsed, and its distance between two rows equals the distance between two bars in the file;
    • Collapsible and CollapsedKinds return what was passed;
    • writing a collapsible chart as PNG raises a ValueError.

The script itself was tested with Node.js against a minimal DOM built from the identifiers of ghdl/ghdl run 34887302325, rendered with StepExclusion.Skipped - 1575 rows, 116 collapsible jobs with 1366 steps, 209 markers:

  • initially exactly the steps of the collapsed jobs are hidden, and the last row moved up by the rows hidden above it;
  • a click on a job's label shows its steps, a second click hides them;
  • a click on a called workflow's line hides all its descendants and keeps the workflow itself visible, a second click restores the previous state.

Known Issues

  • The chart keeps its height: collapsed rows leave empty space at the bottom, and the legend doesn't move.
  • A collapsible file of a big pipeline is large - 4.8 MiB for GHDL's run with all non-skipped steps - since matplotlib writes every label as glyph paths.

Related Issues and Pull-Requests

@pytooling-claude pytooling-claude Bot added this to the v10.1 milestone Sep 15, 2026
@pytooling-claude pytooling-claude Bot added Documentation Improvements or additions to documentation Feature Request Tracing pyTooling.Tracing - Software execution tracing. Unit Tests labels Sep 15, 2026
@codacy-production

codacy-production Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 high · 8 medium · 8 minor

Alerts:
⚠ 17 issues (≤ 0 issues of at least minor severity)

Results:
17 new issues

Category Results
UnusedCode 1 medium
BestPractice 3 medium
Documentation 1 minor
ErrorProne 1 high
Security 2 medium
CodeStyle 7 minor
Complexity 2 medium

View in Codacy

🟢 Metrics 51 complexity · 0 duplication

Metric Results
Complexity 51
Duplication 0

View in Codacy

🟢 Coverage 100.00% diff coverage · +0.04% coverage variation

Metric Results
Coverage variation ✅ +0.04% coverage variation
Diff coverage ✅ 100.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (1d19f95) 15548 13480 86.70%
Head commit (c518df2) 15588 (+40) 13521 (+41) 86.74% (+0.04%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#405) 43 43 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov

codecov Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.89%. Comparing base (1d19f95) to head (4fe421d).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #405      +/-   ##
==========================================
+ Coverage   83.84%   83.89%   +0.04%     
==========================================
  Files          70       70              
  Lines       15548    15588      +40     
  Branches     2345     2349       +4     
==========================================
+ Hits        13036    13077      +41     
+ Misses       2068     2067       -1     
  Partials      444      444              
Flag Coverage Δ
unittests 83.89% <100.00%> (+0.04%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@Paebbels
Paebbels force-pushed the claude/tracing-matplotlib-renderer branch from 0587ea5 to 4edfec0 Compare September 15, 2026 19:58
@Paebbels
Paebbels force-pushed the claude/tracing-collapsible-svg branch from 6d8d7d7 to 52b108d Compare September 15, 2026 19:58
@Paebbels
Paebbels force-pushed the claude/tracing-matplotlib-renderer branch from 4edfec0 to 7408a89 Compare September 19, 2026 00:09
@Paebbels
Paebbels force-pushed the claude/tracing-collapsible-svg branch from 52b108d to 51f9842 Compare September 19, 2026 00:10
@Paebbels
Paebbels force-pushed the claude/tracing-matplotlib-renderer branch from 7408a89 to 4460c10 Compare September 19, 2026 08:40
@Paebbels
Paebbels force-pushed the claude/tracing-collapsible-svg branch from 51f9842 to 024a917 Compare September 19, 2026 08:40
@Paebbels
Paebbels force-pushed the claude/tracing-matplotlib-renderer branch from 4460c10 to 21a57b4 Compare September 19, 2026 09:10
@Paebbels
Paebbels force-pushed the claude/tracing-collapsible-svg branch from 024a917 to af5698a Compare September 19, 2026 09:11
@Paebbels
Paebbels force-pushed the claude/tracing-matplotlib-renderer branch from 21a57b4 to e7f5a12 Compare September 19, 2026 09:14
@Paebbels
Paebbels force-pushed the claude/tracing-collapsible-svg branch from af5698a to 40fff2d Compare September 19, 2026 09:15
@Paebbels
Paebbels force-pushed the claude/tracing-matplotlib-renderer branch from e7f5a12 to 89a53b8 Compare September 19, 2026 12:04
@Paebbels
Paebbels force-pushed the claude/tracing-collapsible-svg branch 3 times, most recently from 4a7bbe7 to b3168a2 Compare September 19, 2026 13:22
@Paebbels
Paebbels force-pushed the claude/tracing-matplotlib-renderer branch 2 times, most recently from 7fa128e to a5abdf8 Compare September 19, 2026 14:09
@Paebbels
Paebbels force-pushed the claude/tracing-collapsible-svg branch 2 times, most recently from f48c306 to e5560d1 Compare September 19, 2026 14:31
@Paebbels
Paebbels force-pushed the claude/tracing-matplotlib-renderer branch 2 times, most recently from c1bda3d to 4c784cc Compare September 19, 2026 14:42
@Paebbels
Paebbels force-pushed the claude/tracing-collapsible-svg branch from e5560d1 to 149adf5 Compare September 19, 2026 14:42
@Paebbels
Paebbels force-pushed the claude/tracing-collapsible-svg branch 2 times, most recently from 7487e62 to 8cfbbab Compare September 19, 2026 23:29
@Paebbels
Paebbels force-pushed the claude/tracing-matplotlib-renderer branch from 9e4cc05 to 29308a0 Compare September 19, 2026 23:29
@pytooling-claude pytooling-claude Bot modified the milestones: v10.1, v10.0 Sep 19, 2026
@Paebbels
Paebbels force-pushed the claude/tracing-matplotlib-renderer branch 7 times, most recently from a1ae378 to 559317b Compare September 20, 2026 10:12
Base automatically changed from claude/tracing-matplotlib-renderer to dev September 20, 2026 10:16
@Paebbels
Paebbels force-pushed the claude/tracing-collapsible-svg branch from 8cfbbab to 26060a3 Compare September 23, 2026 20:58
@pytooling-claude pytooling-claude Bot mentioned this pull request Sep 23, 2026
@Paebbels
Paebbels force-pushed the claude/tracing-collapsible-svg branch 2 times, most recently from bfe804a to 76a693a Compare September 25, 2026 22:28
'MatplotlibRenderer(layout, collapsible=True)' embeds a script, the rows' parents and the distance between two rows:
a click on a called workflow or a job hides or shows the rows below it. Jobs start collapsed ('collapsedKinds').
Every row's label gets an id. Writing a collapsible PNG or PDF file raises a ValueError before anything is drawn.

Ported onto the renderer class of #404: the options are the renderer's, the script is added in '_Write'.

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
Comment thread pyTooling/Tracing/Render/Matplotlib.py Resolved
Comment thread pyTooling/Tracing/Render/Matplotlib.py Resolved
Comment thread pyTooling/Tracing/Render/Matplotlib.py Resolved
* 'CollapsibleGantt.js' and 'CollapsibleGantt.css' in the new resource package 'pyTooling.Resources.Tracing'
  replace the strings '_COLLAPSE_SCRIPT' and '_COLLAPSE_STYLE'. The renderer reads their content with
  'readResourceFile' and embeds it, so the SVG file stays self-contained; 'getResourceFile' returns their paths.
  The placeholder is '/*DATA*/null', so the script is valid JavaScript on its own. 'setup.py' ships '*.js' and
  '*.css' of the package.
* '_CollapsibleSVG' documents 'svg' as the content of the SVG file, not the file.
* The collapsible SVG test checks that the placeholder is replaced and the stylesheet embedded.

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
Comment thread pyTooling/Resources/Tracing/__init__.py Resolved
Comment thread pyTooling/Tracing/Render/Matplotlib.py Resolved
…'__all__' in code order

* 'CollapsibleGantt.css' and 'CollapsibleGantt.js' start with a one-line copyright and a one-line SPDX license.
* The resource package's doc-string drops the sentence on why the files live in 'pyTooling.Resources'.
* '__all__' lists the constants in the order the module defines them.

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
This was referenced Oct 12, 2026
This was referenced Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements or additions to documentation Feature Request Tracing pyTooling.Tracing - Software execution tracing. Unit Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants