unipept / unipept-visualizations

Visualisations used by Unipept, packaged for easy reuse in other projects.
MIT License
18 stars 6 forks source link

Trimming node lables #10

Closed bmesuere closed 5 years ago

bmesuere commented 5 years ago

There is no option to trim node labels. This causes some overlap issues for long EC and GO names.

example:

screen shot 2016-06-27 at 17 32 08

In the previous treeview I added the following piece of code to trim the nodes:

            nodeEnter.append("text")
                .attr("x", function (d) {
                    return isLeaf(d) ? -10 : 10;
                })
                .attr("dy", ".35em")
                .attr("text-anchor", function (d) {
                    return isLeaf(d) ? "end" : "start";
                })
                .text(function (d) {
                    return d.name.length > 33 && (d._children || d.children) ? d.name.substring(0,30).trim()+"..." 
: d.name;
                })
                .style("font", "10px sans-serif")
                .style("fill-opacity", 1e-6);

Original issue by calmalak on Mon Jun 27 2016 at 17:34. Closed by @bmesuere on Mon Jun 27 2016 at 17:57.