Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a method to render multiple output formats #262

Merged
merged 1 commit into from
Sep 25, 2024

Conversation

mdaines
Copy link
Owner

@mdaines mdaines commented Aug 28, 2024

See #259

Adds a renderFormats() method which accepts an array of output formats to render. This avoids redundant parsing and layout when rendering the same graph with multiple output formats. The use case in the linked issue is rendering an SVG and a corresponding image map.

Usage:

const result = viz.renderFormats("digraph { a -> b [href=\"https://example.com\"] }", ["svg", "cmapx"], { engine: "neato" });
result.output // => { "svg": ..., "cmapx": ... }

If rendering is successful, result.output is an object containing the output for each format, keyed by format.

Results from a basic performance test. This compares separate calls to render() with one call to renderFormats():

$ node performance-multiple.mjs 
render, 100 nodes, 10 edges: 1863 in 5.00 s, 372.54 calls/s
render, 1000 nodes, 50 edges: 96 in 5.04 s, 19.05 calls/s
render, 1000 nodes, 500 edges: 60 in 5.01 s, 11.98 calls/s
render, 1000 nodes, 1000 edges: 11 in 5.37 s, 2.05 calls/s
renderFormats, 100 nodes, 10 edges: 2706 in 5.00 s, 541.05 calls/s
renderFormats, 1000 nodes, 50 edges: 162 in 5.02 s, 32.24 calls/s
renderFormats, 1000 nodes, 500 edges: 102 in 5.04 s, 20.25 calls/s
renderFormats, 1000 nodes, 1000 edges: 20 in 5.11 s, 3.91 calls/s

@mdaines mdaines changed the title Viz multiple output formats Add a method to render multiple output formats Aug 30, 2024
@mdaines mdaines force-pushed the viz-multiple-output-formats branch from caf7a61 to de27efd Compare September 24, 2024 16:52
@mdaines mdaines force-pushed the viz-multiple-output-formats branch from b16b5e2 to 57f0fc0 Compare September 25, 2024 17:59
@mdaines mdaines marked this pull request as ready for review September 25, 2024 18:00
@mdaines mdaines merged commit 2837bae into v3 Sep 25, 2024
5 checks passed
@mdaines mdaines deleted the viz-multiple-output-formats branch September 25, 2024 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant