Skip to content

Commit

Permalink
[UI] Use elkjs bundled (#670)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykalmax authored Apr 7, 2023
1 parent 5fecad2 commit 295789f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions web/client/src/library/components/graph/help.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ELK from 'elkjs/lib/elk-api'
import ELK from 'elkjs/lib/elk.bundled.js'
import { MarkerType } from 'reactflow'
import { isArrayNotEmpty } from '../../../utils'

Expand Down Expand Up @@ -48,9 +48,7 @@ interface GraphOptions {
algorithm?: string
}

const elk = new ELK({
workerUrl: '/node_modules/elkjs/lib/elk-worker.min.js',
})
const elk = new ELK()

const ALGORITHM_LAYERED = 'layered'

Expand Down Expand Up @@ -87,7 +85,7 @@ export async function getNodesAndEdges({
const layout = await elk.layout(graph)
const nodes: GraphNode[] = []

layout.children?.forEach((node, idx: number) => {
layout.children?.forEach(node => {
const output = nodesMap[node.id]

if (output == null) return
Expand All @@ -101,8 +99,8 @@ export async function getNodesAndEdges({
}

output.position = {
x: node.x == null ? 0 : -node.x,
y: node.y == null ? 0 : -node.y,
x: node.x == null ? 0 : -node.x * 2,
y: node.y == null ? 0 : -node.y * 1.5,
}

nodes.push(output)
Expand Down

0 comments on commit 295789f

Please sign in to comment.