- 
                Notifications
    You must be signed in to change notification settings 
- Fork 6
expanding bot names in main layout #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -35,37 +35,44 @@ d3.selection.prototype.tspans2 = function(lines, lh) { | |
| return '<tspan fill="' + ((['errors', 'error', 'red'].indexOf(k) != -1) ? 'red' : '') + '">' + d[k] + '</tspan>' | ||
| }).join('') | ||
| }) | ||
| } | ||
| } | ||
|  | ||
|  | ||
| d3.wordwrap = function (line, maxCharactersPerLine, maxLines = 2) { | ||
| var parts = line.split(/([^a-z][a-z]*)/), //split at non-words | ||
| d3.wordwrap = function (line = '', maxCharactersPerLine = 43, maxLines = 3) { | ||
| const regexChecks = [/_/ig, /-/ig, /([A-Z])/g]; | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. many bot names are not following a standard naming structure... As such you can find the following names: This regex will check all forms and separate accordingly. | ||
| var parts = [], | ||
| lines = [], | ||
| words = [], | ||
| maxChars = maxCharactersPerLine || 40 | ||
| words = []; | ||
|  | ||
| const parts = regexChecks.reduce((accumulator, regexCheck, index) => { | ||
| if(line.search(regexCheck) >= 0) { | ||
| accumulator.push(line.replace(regexChecks[index], (index == 2 ? ' $1' : ' ')).split(' ')); | ||
| } | ||
| return accumulator; | ||
| }, []); | ||
|  | ||
| parts.forEach(function (part) { | ||
| if (part) { | ||
| if (words.length > 0 && (words.join('').length + part.length) > maxChars) { | ||
| lines.push(words.join('')) | ||
| if (words.length > 0 && (words.join(' ').length + part.length) > maxCharactersPerLine) { | ||
| lines.push(words.join(' ')) | ||
| words = [] | ||
| } | ||
| //if it's too long, chop it | ||
| while (part.length > maxChars) { | ||
| lines.push(part.slice(0, maxChars - 1) + '-') | ||
| part = part.slice(maxChars - 1) | ||
| //if the word is too long, chop it | ||
| while (part.length > maxCharactersPerLine) { | ||
| lines.push(part.slice(0, maxCharactersPerLine - 1) + '-') | ||
| part = part.slice(maxCharactersPerLine - 1) | ||
| } | ||
| words.push(part) | ||
| } | ||
| }) | ||
|  | ||
| if (words.length) { | ||
| lines.push(words.join('')) | ||
| lines.push(words.join(' ')) | ||
| } | ||
|  | ||
| if (lines.length > maxLines) { | ||
| lines = lines.slice(0, maxLines) | ||
| lines[1] += '...' | ||
| lines[maxLines - 1] += '...' | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seemed more efficient instead of hardcoding | ||
| } | ||
|  | ||
| return lines | ||
|  | @@ -589,7 +596,7 @@ class Tree extends React.Component { | |
| }) | ||
|  | ||
| nodeText.tspans2(function (d) { | ||
| return d3.wordwrap((d.label || '').toString().replace(/_/ig, ' '), 20) //12 | ||
| return d3.wordwrap((d.label || '')); | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didnt see a reason to do any of this here. Let the function do the work. | ||
| }) | ||
|  | ||
| nodeText.call(me.getBB) | ||
|  | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maxCharactersPerLine updated to have a default of 43, maxLines updated to 3 (43 * 3 = 129, most of AWS names are 128 maximum from what I could find).