* Create a new graph instance. * @param options - Options for creating the graph. * @returns The created graph instance. * @group Graph * @internal * @example * ```ts * const graph = createGraph(); * console.log(graph); * ```
(options: StoreOptions = {})
| 99 | * ``` |
| 100 | */ |
| 101 | function createGraph(options: StoreOptions = {}): dia.Graph { |
| 102 | const { cellModel, cellNamespace = DEFAULT_CELL_NAMESPACE, graph } = options; |
| 103 | const newGraph = |
| 104 | graph ?? |
| 105 | new dia.Graph( |
| 106 | {}, |
| 107 | |
| 108 | { |
| 109 | cellNamespace: { |
| 110 | ...DEFAULT_CELL_NAMESPACE, |
| 111 | // @ts-expect-error Shapes is not a valid type for cellNamespace |
| 112 | ...cellNamespace, |
| 113 | }, |
| 114 | cellModel, |
| 115 | } |
| 116 | ); |
| 117 | return newGraph; |
| 118 | } |
| 119 | /** |
| 120 | * Building block of `@joint/react`. |
| 121 | * It listen to cell changes and updates UI based on the `dia.graph` changes. |