javascriptmxgraph

MxGraph - Add background to edge label


I'm trying to add background to the edges label but it doesn't seem to be working. any suggestions?

here's my code:

graph.insertEdge(
  parent,
  r.id,
  r.name,
  src,
  target,
  'edgeStyle=orthogonalEdgeStyle;fontSize=14;fontColor=#000;fillColor=#fff;strokeColor=black'
);

this is what I am trying to achieve:

enter image description here

the current result:

enter image description here


Solution

  • You could use labelBackgroundColor style. Like this:

    graph.insertEdge(
     .....
     'labelBackgroundColor=red'
    );
    

    To figure out things like this, I would recommend you do it manually using draw.io (diagrams.net) and then just copy the style.