mirror of https://github.com/grafana/grafana
[v11.0.x] Nodegraph: Fix issue with rendering single node (#86195)
Nodegraph: Fix issue with rendering single node (#84930)
Fix for single node graph case
(cherry picked from commit aba65747c9
)
Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com>
pull/86221/head
parent
ebdea3e5c2
commit
c7c5c58b5f
@ -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