Skip to content

Commit a28e116

Browse files
committed
Parcoords: ellipsize long labels; show full text in tooltip
1 parent fbc0296 commit a28e116

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/traces/parcoords/parcoords.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,20 @@ module.exports = function(root, svg, styledData, layout, callbacks) {
598598
axisTitle
599599
.attr('transform', 'translate(0,' + -c.axisTitleOffset + ')')
600600
.text(function(d) {return d.label;})
601-
.each(function(d) {Drawing.font(axisTitle, d.model.labelFont);});
601+
.each(function(d) {Drawing.font(axisTitle, d.model.labelFont);})
602+
.each(function(d) {
603+
// Ellipsize long labels
604+
var maxWidth = d.xScale(1) - 5;
605+
while(this.textContent.length > 2 &&
606+
this.getComputedTextLength() > maxWidth) {
607+
this.textContent = this.textContent.slice(0, -2) + '…';
608+
}
609+
});
610+
611+
// Tooltip
612+
axisTitle.enter()
613+
.append('title')
614+
.text(function(d) {return d.label;});
602615

603616
var axisExtent = axisOverlays.selectAll('.axisExtent')
604617
.data(repeat, keyFun);

0 commit comments

Comments
 (0)