Skip to content

EdgeConfig such as labelpos is not respected during Dagre layout #473

@elvin-hwang

Description

@elvin-hwang

I'm attempting to pass in EdgeConfig to my Dagre graph during layout, but I found passing in { labelpos: 'c' | 'l' | 'r' } does not change the output of the label position and always uses the default 'r' configuration. Same can be said about other EdgeConfig properties, such as labeloffset, minlen, weight. (also labeloffset is misspelled as labeloffest in EdgeConfig)

Here is how I'm layouting the dagre graph

import Dagre, { Edge, layout } from '@dagrejs/dagre'

const dagreGraph = new Dagre.graphlib.Graph({ multigraph: true, compound: true })
    .setDefaultEdgeLabel(() => ({}))
    .setDefaultNodeLabel(() => ({}))

 dagreGraph.setGraph({
    rankdir: graphOptions.rankdir,
    ranksep: graphOptions.ranksep,
    edgesep: graphOptions.edgesep,
    nodesep: graphOptions.nodesep,
  })

...
add nodes
...
add edges
...
    dagreGraph.setEdge(
      edge.source,
      edge.target,
      { label: edge.displayLabel, width: labelWidth, height: labelHeight },
      edgeId,
    )
...

layout(dagreGraph, { labelpos: 'c', labeloffest: 1000, minlen: 1000, weight: 1000 })

Calling layout with and without EdgeConfig option returns the same coordinates for the Edge label

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions