How to create new line in Plot.ly JS title
Use <br>
to break lines in plotly strings.
To have more control, I'm doing like this for multiple-lines title:
multipleStringLines: (title) => {
if (title.length > 20) { // check if greater than threshold!
let y_axis = title.split(' '); //break into words
let interval = title.split(' ').length / 2; //2-lines
return y_axis.slice(0, interval).join(' ') + '<br>' + y_axis.slice(interval, y_axis.length).join(' ');
}
return title;
}