Skip to content

New: Add SVG export#111

Merged
AlexIchenskiy merged 2 commits into
release/1.0.0from
new/add-svg-export
Jul 16, 2026
Merged

New: Add SVG export#111
AlexIchenskiy merged 2 commits into
release/1.0.0from
new/add-svg-export

Conversation

@AlexIchenskiy

Copy link
Copy Markdown

This PR adds SVG export using view.getSVG() on the default view, and graphToSVG(graph) standalone. It serializes nodes and edges with their styling and node images (embedded as data URIs, so the output is self-contained).

However, OrbMapView isn't supported as without the map tiles the SVG would just be the bare graph, so getSVG() there throws instead of returning something half-useful.

@AlexIchenskiy AlexIchenskiy self-assigned this Jul 13, 2026

@tonilastre tonilastre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a great addition. I've added some nitpicking commments.

Comment thread src/renderer/svg/defs.ts Outdated
Comment on lines +7 to +15
private readonly _filterRegion?: IRectangle;

constructor(filterRegion?: IRectangle) {
this._filterRegion = filterRegion;
}

get filterRegion(): IRectangle | undefined {
return this._filterRegion;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can all this be replaced with

constructor(public readonly filterRegion?: IRectangle) {}

Comment thread src/renderer/svg/index.ts
Comment on lines +131 to +133
const center = node.getCenter();
const radius = node.getBorderedRadius();
const pad = isShadowEnabled ? shadowReach(node.hasShadow(), node.getStyle()) : 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice!

Comment thread src/renderer/svg/utils.ts Outdated
@@ -0,0 +1,37 @@
export type SVGAttributes = Record<string, string | number | undefined | null>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I missing.

Comment thread src/renderer/svg/defs.ts Outdated
@@ -0,0 +1,36 @@
import { IRectangle } from '../../common';

export class SVGDefs {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Btw do we want to define ISVGDefs and this class can implement it so you can reference ISVGDefs in the rest of the code which uses the interface only. Right now, the class is being used in other types.

Comment thread src/views/orb-map-view.ts Outdated
}

getSVG(): string {
throw new Error('Method not implemented.');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe some better error like SVG export is not supported on map view.

@AlexIchenskiy AlexIchenskiy merged commit 01f3194 into release/1.0.0 Jul 16, 2026
2 checks passed
@AlexIchenskiy AlexIchenskiy deleted the new/add-svg-export branch July 16, 2026 07:17
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.

2 participants