ricklupton / ipysankeywidget

IPython / Jupyter Sankey diagram widget
MIT License
174 stars 24 forks source link

Break node labels into multiple lines? #87

Closed owoodhansen closed 1 year ago

owoodhansen commented 1 year ago

Hi again Rick

Some of my node labels are long and I'd therefore like to break/wrap them onto two lines. Imagine some node called "target D with a very long title and whose uncle is called deidre". I could extend the margins to accomodate, but it is not a nice solution if only one of many nodes are very long.

I looked into some basic CSS styling, the ipywidgets documentation, and your ipysankeywidget > more examples > styling without success.

I tried using modifying your CSS suggestion

%%html
<style>
   .sankey .node {
       font-style: italic;
   }
</style>

with width: 5px; word-break: break-all; and overflow-wrap: break-word to no avail (but I get italics obv)

ricklupton commented 1 year ago

It should work to put line breaks in the title with \n, like modifying this example from "More examples":

nodes = [
    # Added \n in 'title'
    {'id': 'B', 'title': 'Middle\nnode', 'style': 'process' },
]
owoodhansen commented 1 year ago

Worked perfect.