plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

Sankey Diagram Not Resolving HTML Tags in Labels

Open JMante1 opened this issue 5 years ago • 4 comments

When using html tags in the labels of a Sankey diagram the html itself is displayed rather than the resolved form (even though in the hover labels it is resolved).

I have added an example of code that generates this error below:

import plotly

data = dict(
    type='sankey',
    node = dict(
      pad = 15,
      thickness = 20,
      line = dict(
        color = "black",
        width = 0.5
      ),
      label = ['<a href="https://plot.ly/python/sankey-diagram/">A1</a>', 
                '<a href="https://plot.ly/python/sankey-diagram/">A2</a>', 
                '<a href="https://plot.ly/python/sankey-diagram/">B1</a>', 
                '<a href="https://plot.ly/python/sankey-diagram/">B2</a>', 
                '<a href="https://plot.ly/python/sankey-diagram/">C1</a>', 
                '<a href="https://plot.ly/python/sankey-diagram/">C2</a>'],
      color = ["blue", "blue", "blue", "blue", "blue", "blue"]
    ),
    link = dict(
      source = [0,1,0,2,3,3],
      target = [2,3,3,4,4,5],
      value = [8,4,2,8,4,2]
  ))

layout =  dict(
    title = "Basic Sankey Diagram",
    font = dict(
      size = 10
    )
)

fig = dict(data=[data], layout=layout)
plotly.offline.plot(fig, filename = 'issue.html', auto_open=True)


JMante1 avatar Apr 07 '19 03:04 JMante1

Thanks for the report @JMante1. @antoinerg, as things stand right now, do you expect HTML formatting to work in Sankey labels? Thanks!

jonmmease avatar Apr 08 '19 13:04 jonmmease

Thank you @JMante1 for reporting this issue!

do you expect HTML formatting to work in Sankey labels?

@jonmmease I expected it to work but it seems like this feature wasn't implemented. I would consider this is a bug. I opened an issue here: https://github.com/plotly/plotly.js/issues/3742

antoinerg avatar Apr 08 '19 16:04 antoinerg

Thanks @antoinerg!

jonmmease avatar Apr 09 '19 09:04 jonmmease

The same happens for parcats:

The following code:

    dim_nuevas = go.parcats.Dimension(
        values=df[elecciones_nuevas],
        categoryorder='category ascending',
        label='Elecciones Nuevas<br>'
    )

Will result in:

newplot

jsulopzs avatar Jan 15 '24 20:01 jsulopzs