mirror of https://github.com/grafana/grafana
Nodegraph: Fix issue with rendering single node (#84930)
Fix for single node graph casepull/85163/head
parent
dd93d9958d
commit
aba65747c9
@ -1,4 +1,4 @@ |
||||
import { CorsWorker as Worker } from 'app/core/utils/CorsWorker'; |
||||
|
||||
export const createWorker = () => new Worker(new URL('./layout.worker.js', import.meta.url)); |
||||
export const createMsaglWorker = () => new Worker(new URL('./layoutMsagl.worker.js', import.meta.url)); |
||||
export const createMsaglWorker = () => new Worker(new URL('./layoutLayered.worker.js', import.meta.url)); |
||||
|
@ -0,0 +1,10 @@ |
||||
import { layout } from './layeredLayout'; |
||||
|
||||
describe('layout', () => { |
||||
it('can render single node', () => { |
||||
const nodes = [{ id: 'A', incoming: 0 }]; |
||||
const edges: unknown[] = []; |
||||
const graph = layout(nodes, edges); |
||||
expect(graph).toEqual([[{ id: 'A', incoming: 0, x: 0, y: 0 }], []]); |
||||
}); |
||||
}); |
@ -0,0 +1,8 @@ |
||||
import { layout } from './layeredLayout'; |
||||
|
||||
// Separate from main implementation so it does not trip out tests
|
||||
addEventListener('message', async (event) => { |
||||
const { nodes, edges, config } = event.data; |
||||
const [newNodes, newEdges] = layout(nodes, edges, config); |
||||
postMessage({ nodes: newNodes, edges: newEdges }); |
||||
}); |
Loading…
Reference in new issue