Skip to content

Commit f549efa

Browse files
committed
fix graph passing to fromGraphLib
1 parent d70a9f4 commit f549efa

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/joint-layout-directed-graph/DirectedGraph.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,14 @@ export namespace DirectedGraph {
4141
[key: string]: any;
4242
}
4343

44+
interface fromGraphLibOptions {
45+
graph?: dia.Graph;
46+
[key: string]: any;
47+
}
48+
4449
export function layout(graph: dia.Graph | dia.Cell[], opt?: LayoutOptions): g.Rect;
4550

4651
export function toGraphLib(graph: dia.Graph, opt?: toGraphLibOptions): any;
4752

48-
export function fromGraphLib(glGraph: any, opt?: { [key: string]: any }): dia.Graph;
53+
export function fromGraphLib(glGraph: any, opt?: fromGraphLibOptions): dia.Graph;
4954
}

packages/joint-layout-directed-graph/DirectedGraph.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ export const DirectedGraph = {
173173
graph.startBatch('layout');
174174

175175
DirectedGraph.fromGraphLib(glGraph, {
176+
graph,
176177
importNode: opt.importNode,
177178
importEdge: opt.importEdge,
178179
setPosition: opt.setPosition,
@@ -217,7 +218,7 @@ export const DirectedGraph = {
217218

218219
var importNode = opt.importNode || util.noop;
219220
var importEdge = opt.importEdge || util.noop;
220-
var graph = new dia.Graph();
221+
var graph = opt.graph || new dia.Graph();
221222

222223
// Import all nodes.
223224
glGraph.nodes().forEach(function(node) {

0 commit comments

Comments
 (0)