Estoy tratando de estructurar mi salida en la visualización D3.js y estoy usando \n retornos de línea, pero JS no los lee, ¿alguna idea sobre cómo se puede resolver?
Muchas gracias por adelantado :)
.on('mousemove', function(d) { tooltip .style('top', d3.event.pageY - 10 + 'px') .style('left', d3.event.pageX + 10 + 'px') .text(`Number of clones in the class: ${d.data.value/2} \r\n \n \r Code of the class: ${d.data.code} Lines at which the clone appears: ${d.data.lines}`); })puede usar tspan para cada nueva línea y jugar con los atributos dy para la altura de la línea
.on('mousemove', function(d) { tooltip .style('top', d3.event.pageY - 10 + 'px') .style('left', d3.event.pageX + 10 + 'px') .html(`<tspan x='0' dy='1.2em'>Number of clones in the class: ${d.data.value/2}</tspan> <tspan x='0' dy='1.2em'>Code of the class: ${d.data.code}</tspan> <tspan x='0' dy='1.2em'>Lines at which the clone appears: ${d.data.lines}</tspan>`); })