diff --git a/client/app/scripts/charts/node.js b/client/app/scripts/charts/node.js
index ccfca1869..35d527b7e 100644
--- a/client/app/scripts/charts/node.js
+++ b/client/app/scripts/charts/node.js
@@ -66,12 +66,29 @@ const Node = React.createClass({
- {this.props.label}
- {this.props.subLabel}
+
+ {this.ellipsis(this.props.label, 14)}
+
+
+ {this.ellipsis(this.props.subLabel, 12)}
+
);
},
+ ellipsis: function(text, fontSize) {
+ const maxWidth = this.props.scale(4);
+ const averageCharLength = fontSize / 1.5;
+ const allowedChars = maxWidth / averageCharLength;
+ let truncatedText = text;
+ let trimmedText = text;
+ while (text && trimmedText.length > 1 && trimmedText.length > allowedChars) {
+ trimmedText = trimmedText.slice(0, -1);
+ truncatedText = trimmedText + '...';
+ }
+ return truncatedText;
+ },
+
handleMouseEnter: function(ev) {
AppActions.enterNode(ev.currentTarget.id);
},