@@ -9,7 +9,7 @@ import { graphDatasetActions, graphDatasetAtom, sigmaGraphAtom } from "../graph"
99import { dataGraphToFullGraph } from "../graph/utils" ;
1010import { resetCamera } from "../sigma" ;
1111import { LAYOUTS } from "./collection" ;
12- import { LayoutMapping , LayoutQuality , LayoutState } from "./types" ;
12+ import { type Layout , LayoutMapping , LayoutQuality , LayoutState } from "./types" ;
1313
1414function getEmptyLayoutState ( ) : LayoutState {
1515 return { quality : { enabled : false , showGrid : true } , type : "idle" } ;
@@ -34,7 +34,7 @@ export const layoutStateAtom = atom<LayoutState>(getLocalStorageLayoutState());
3434 * Actions:
3535 * ********
3636 */
37- export const startLayout = asyncAction ( async ( id : string , params : unknown ) => {
37+ export const startLayout = asyncAction ( async ( id : Layout [ "id" ] , params : Record < string , unknown > ) => {
3838 const { setNodePositions } = graphDatasetActions ;
3939 const dataset = graphDatasetAtom . get ( ) ;
4040
@@ -62,7 +62,19 @@ export const startLayout = asyncAction(async (id: string, params: unknown) => {
6262
6363 // Async layout
6464 if ( layout && layout . type === "worker" ) {
65- const worker = new layout . supervisor ( sigmaGraphAtom . get ( ) , { settings : params } ) ;
65+ const graph = sigmaGraphAtom . get ( ) ;
66+
67+ // If layout parameter has a `getNodeFixedAttribut`, then we have to set the 'fixed'
68+ // attribut in sigma's graph
69+ if ( "getNodeFixedAttribut" in params && params . getNodeFixedAttribut ) {
70+ const fixedAttribut = `${ params . getNodeFixedAttribut } ` ;
71+ graph . updateEachNodeAttributes ( ( id , attrs ) => ( {
72+ ...attrs ,
73+ fixed : dataset . nodeData [ id ] [ fixedAttribut ] === true ,
74+ } ) ) ;
75+ }
76+
77+ const worker = new layout . supervisor ( graph , { settings : params } ) ;
6678 worker . start ( ) ;
6779 layoutStateAtom . set ( ( prev ) => ( { ...prev , type : "running" , layoutId : id , supervisor : worker } ) ) ;
6880 }
0 commit comments