rete icon indicating copy to clipboard operation
rete copied to clipboard

How to use the ELK radial algorithm?

Open boop5 opened this issue 11 months ago • 6 comments

I'm just following the guide for angular using the autoarrange-plugin. I do want to use another arrange algorithm though. Most of them seem to work just fine (like elk.mrtree). But I cant get elk.radial working. How can I do that?

I've tried it like this

const arrange = new AutoArrangePlugin<Schemes>();
// ...
area.use(arrange)
// ...
arrange.addPreset(ArrangePresets.classic.setup());
// ...
await arrange.layout({ applier, options: {
    algorithm: 'elk.radial'
}});

Here is a simplified stackblitz of what I've tried https://stackblitz.com/edit/stackblitz-starters-3fm3cd?file=src%2Fmain.ts

This is how it looks if I don't specify an algorithm

image

This is the same graph but with algorithm: 'elk.radial'

image

This is with elk.mrtree algorithm

image

boop5 avatar Aug 30 '23 16:08 boop5

the layout method returns a debugging information:

  • URL to online ELK editor: https://rtsys.informatik.uni-kiel.de/elklive/json.html
  • Resulting ELK JSON: source property

Based on this, it shows the scheme

I guess this algorithm doesn't support a ports. After removing _port_output/_port_input in edges, it shows this: image

If this is what you need, I can find solutions to achieve this using a plugin

Ni55aN avatar Sep 04 '23 08:09 Ni55aN

Yes, this is exactly what I'm looking for!

boop5 avatar Sep 04 '23 08:09 boop5

@boop5 at the moment, I haven't found an elegant (or nearly) solution on how to flexibly include/exclude/modify certain fields in the ELK.js scheme

If you need it badly, there is a solution, but I'll recommend to use it carefully (at least remove ^ from "rete-auto-arrange-plugin": "^2.0.0")

// @ts-ignore
class PortlessAutoArrangePlugin extends AutoArrangePlugin<Schemes> {
  nodeToLayoutChild(...args: any[]) {
    // @ts-ignore
    const data = super.nodeToLayoutChild(...args)

    return {
      ...data,
      ports: undefined
    }
  }
  getPortId(id: string) {
    return id
  }
}

const arrange = new PortlessAutoArrangePlugin();

arrange.addPreset(ArrangePresets.classic.setup());

area.use(arrange);

console.log(await arrange.layout({
  options: {
    algorithm: 'elk.radial'
  }
}))

As you can see @ts-ignore is used here, as it breaks the interface and inheritance is tricky.

Ni55aN avatar Sep 07 '23 15:09 Ni55aN

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

rete-js[bot] avatar Dec 31 '23 01:12 rete-js[bot]

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

rete-js[bot] avatar Mar 10 '24 01:03 rete-js[bot]

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

rete-js[bot] avatar Apr 14 '24 02:04 rete-js[bot]

This issue was closed because it has been stalled for 10 days with no activity.

rete-js[bot] avatar May 05 '24 01:05 rete-js[bot]