Skip to content
  1. Ogma@5
  2. 3 migration guide

Ogma@5.3 migration guide

Ogma@5.3 introduces some changes to the transformation API that may require adjustments in your codebase. This guide outlines the key modifications and how to adapt your code accordingly.

Node grouping

Ogma@5.3 introduces a new way to increase the performance of the layout by merging running it once for all the nodes inside of the groups. This is done by returning the layout options in the onGroupUpdated callback.

So if you had a code like this:

js
ogma.group({
  groupIdFunction: (node) => ...,
  showContents: true,
  onGroupUpdated: (group) => {
    return ogma.layouts.force({ nodes: group });
  }
});

You should now return the layout options instead of the layout itself:

js
ogma.group({
  groupIdFunction: (node) => ...,
  showContents: true,
  onGroupUpdated: (group) => {
    return { layout: 'force', params: {...} };
  }
});

Same goes for the onGroupsUpdated callback on ogma.transformations:

js
ogma.transformations.onGroupsUpdated((groups) => {
  return { layout: 'force', params: {...} };
});

Alternatively, you can return a promise that resolves to the final nodes positions:

js
ogma.group({
  groupIdFunction: (node) => ...,
  showContents: true,
  onGroupUpdated: (group) => {
    return yourPlacementFunction(group);
  }
});

For more details you should refer to the API documentation of the grouping transformation options.

GPU layout

One of the main benefits of the new grouping API is that it allows you to use the GPU layout for the groups. This is done by returning the gpu layout in the onGroupUpdated callback:

js
ogma.group({
  groupIdFunction: (node) => ...,
  showContents: true,
  onGroupUpdated: (group) => {
    return { layout: 'force', params: { gpu: true, ...} };
  }
});

So in addition to the huge performance boost that is delivered by the new grouping API, you can also benefit from the GPU layout for the groups to make it even faster and bring better quality to the compound nodes.