Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sankey: node labels do not render HTML tags #3742

Closed
antoinerg opened this issue Apr 8, 2019 · 9 comments · Fixed by #5531
Closed

sankey: node labels do not render HTML tags #3742

antoinerg opened this issue Apr 8, 2019 · 9 comments · Fixed by #5531
Assignees
Labels
bug something broken
Milestone

Comments

@antoinerg
Copy link
Contributor

As reported on plotly.py: plotly/plotly.py#1499

Note that in hover labels, HTML tags are rendered properly.

See Codepen: https://codepen.io/antoinerg/pen/XQNjNE

@etpinard
Copy link
Contributor

Related: #2859 (might be nice to tackle these two bugs at the same time)

@JMante1
Copy link

JMante1 commented Apr 17, 2019

This seems similar to the issue reported and solved here: #1792
I am rather new to this but I think by adding the .call(svgTextUtils.convertToTspans, gd) line (as in 198 of https://github.com/plotly/plotly.js/blob/e5b8c7197aa68cd919a5c517226206cdefbbbcb1/src/traces/bar/plot.js which does allow html tags to work) after line 1035 of https://github.com/plotly/plotly.js/blob/e5b8c7197aa68cd919a5c517226206cdefbbbcb1/src/traces/sankey/render.js should fix the issue?

@etpinard
Copy link
Contributor

@JMante1 your hypothesis sounds right to me. Wanna try making a PR for us? Thanks!

@JMante1
Copy link

JMante1 commented Apr 24, 2019

Hi, I am having trouble compiling the plotly library on my computer to test the hypothesis. I do have a forked branch with the edits that I think should work though.

@antmoreau
Copy link

Any news on that issue ?

@mallikkommaraju
Copy link

Hi, I am also eagerly waiting the bug fix. Any news??

Thank you in advance!

@Raimondo-M
Copy link

Same issue here, there is any news about it?

@JMante1
Copy link

JMante1 commented Oct 17, 2020

I had a look at it but couldn't get it to work. The same solution doesn't work as I proposed above. I think that is because for the bar you have text append whereas for sankey it is just node label. I can get something that looks somewhat right if you change 1047 in render.js in sankey as shown below. However, this only fixes the display of links and not breaks, additionally links do not appear to be clickable though if you right click and say open in a new tab then it does take you to the correct website.

nodeLabelTextPath.enter()
        .append('tspan')
        .classed(c.cn.nodeLabelTextPath, true)
        .attr('alignment-baseline', 'middle')
		.attr('xlink:href', function(d) {return '#' + d.uniqueNodeLabelPathId;})
        .attr('startOffset', nodeTextOffset)
        .style('fill', nodeTextColor);

    nodeLabelTextPath
        .html(function(d) {return d.horizontal || d.node.dy > 5 ? d.node.label : '';})
        .attr('text-anchor', function(d) {return d.horizontal && d.left ? 'end' : 'start';});

@alexcjohnson
Copy link
Collaborator

FYI we cannot use .html - this presents a security risk in some contexts, notably Chart Studio. One way or another it needs to go through svgTextUtils.convertToTspans.

@archmoj archmoj self-assigned this Mar 4, 2021
@archmoj archmoj added this to the NEXT milestone Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants