dagre-d3 icon indicating copy to clipboard operation
dagre-d3 copied to clipboard

HTML in edge label not rendering

Open hahla opened this issue 10 years ago • 6 comments

Using latest version from bower.

Got a nice graph displayed, want to add tooltips or other label components, starting with a simple html test though and it's rendering screen shot 2015-01-13 at 7 15 35 pm as plain-text.

label = { label: 'click me im so

clickable
'}; g.setEdge(srcIdx, targetIdx, label);

Here's a screenshot what it looks like zoomed in by the edge in question.

Uploading Screen Shot 2015-01-13 at 7.15.35 PM.png . . .

hahla avatar Jan 14 '15 03:01 hahla

As far as I know, the HTML detection is based on the first few characters. dagre treats your label as HTML label if it starts with a HTML tag, so simply change it to something like this:

label = { label: '<div> click me im so <div onclick="alert(123);"> clickable </div> </div>'};

Loxos avatar Jan 19 '15 12:01 Loxos

When setting the node label you can also specify a "labelType" as "html". Take a look here: https://github.com/Netflix/Lipstick/blob/master/lipstick-server/app/public/js/workflow/graph/graph.js#L227

alienrobotwizard avatar Jan 19 '15 16:01 alienrobotwizard

@thedatachef Thanks I'll take a look at that. Note I'm referring to edge labels not node labels

hahla avatar Jan 23 '15 18:01 hahla

It's the same for both. https://github.com/Netflix/Lipstick/blob/master/lipstick-server/app/public/js/workflow/graph/graph.js#L247

alienrobotwizard avatar Jan 23 '15 21:01 alienrobotwizard

Just for posterity, I was having this problem (5 years later). The solution for this was that the labelType is an attribute of the node itself, while in the case of edges, the labelType attribute is a property of the config object.

e.g.

        node: {
        id: "4321",
        label: "<div>this is an html label</div>,
        labelType: "html",
        class: "nodeWithHTML",
        config: {}
        }

        edge: {
        id: "1234",
        source: "4321",
        target: "9876",
        label: "<div>this is an html label</div>,
        config: { labelType: "html" },
        }

Lathrisk avatar Apr 08 '20 15:04 Lathrisk

is there documentation somewhere on all the different attributes of the node itself and also for the edge? or pointers to source code I could read?

for example in the dagre-d3/demo/style-attrs.html i see:

g.setEdge("A", "E", {
  label: "Arrowhead class",
  arrowheadClass: 'arrowhead'
});

but I do not see a reference to arrowheadClass anywhere in the source code

terrencekuo avatar Jun 12 '20 07:06 terrencekuo