Unified rendering module for diagrams and charts. Consolidates all diagram/chart-to-PNG rendering into a single utility class with static methods.
Before ObjVisual, rendering logic was duplicated across several modules:
ObjTemplate.render_mermaid contained the full Mermaid CLI rendering pipelineObjWorkflowVisual.visualise_piper called processpiper.text2diagram.render directlyObjDecisionSwitchVisual.generate_sankey_plotly built and rendered Plotly Sankey figures inlineObjVisual extracts the rendering mechanics into reusable static methods. The consumer modules now delegate to ObjVisual while retaining their domain-specific data preparation and palette resolution.
Standalone utility class. All methods are @staticmethod -- no database connection, no ObjData inheritance, no instance state.
render_mermaid(mermaid_text, output_path, accent, accent2, width) -> strRenders Mermaid diagram text to PNG using the mmdc CLI (Mermaid CLI).
.mmd file in local.documents (mmdc snap cannot access /tmp).mmd file in a finally blockDependencies: mmdc CLI (npm install -g @mermaid-js/mermaid-cli)
render_piper(flow_text, output_path) -> strWraps processpiper.text2diagram.render() for BPMN-style workflow diagrams.
processpiper gracefully (returns empty string)Dependencies: processpiper Python package
render_plotly_sankey(labels, sources, targets, values, node_colours, output_path, title, width, height) -> strRenders a Plotly Sankey diagram to PNG using the kaleido engine at 2x scale.
Dependencies: plotly, kaleido Python packages
render_plotly_bar(labels, values, output_path, accent, title, width, height) -> strRenders a simple horizontal bar chart to PNG.
Dependencies: plotly, kaleido Python packages
lighten(hex_colour, factor) -> strHelper to blend a hex colour toward white. Used internally by render_mermaid for theme generation.
| Consumer | Method | Delegation |
|---|---|---|
ObjTemplate.render_mermaid |
Thin wrapper resolving palette, delegates to ObjVisual.render_mermaid |
|
ObjDecisionSwitchVisual.generate_sankey_plotly |
Prepares graph data, delegates rendering to ObjVisual.render_plotly_sankey |
|
ObjWorkflowVisual.visualise_piper |
Builds flow text, delegates rendering to ObjVisual.render_piper |
All external dependencies are imported lazily inside each method and handled gracefully if missing:
mmdc CLI (Mermaid)processpiper (ProcessPiper)plotly + kaleido (Plotly charts)