Browse Source

Remove the "must be a box" requirement.

Theoretically, there are multiple node shape types that this could apply to.
codeClimate
Coleman Kane 9 years ago
parent
commit
b5c59a547d
2 changed files with 5 additions and 5 deletions
  1. +2
    -2
      docs/network/nodes.html
  2. +3
    -3
      lib/network/modules/components/shared/Label.js

+ 2
- 2
docs/network/nodes.html View File

@ -375,8 +375,8 @@ network.setOptions(options);
<td class="indent">font.textAlign</td> <td class="indent">font.textAlign</td>
<td>String</td> <td>String</td>
<td><code>'center'</code></td> <td><code>'center'</code></td>
<td>If shape is box, this can be set to 'left' to make the label left-aligned. Otherwise,
defaults/resets to 'center'.</td>
<td>This can be set to 'left' to make the label left-aligned. Otherwise,
defaults to 'center'.</td>
</tr> </tr>
<tr> <tr>
<td>group</td> <td>group</td>

+ 3
- 3
lib/network/modules/components/shared/Label.js View File

@ -127,9 +127,9 @@ class Label {
// configure context for drawing the text // configure context for drawing the text
ctx.font = (selected && this.nodeOptions.labelHighlightBold ? 'bold ' : '') + fontSize + "px " + this.fontOptions.face; ctx.font = (selected && this.nodeOptions.labelHighlightBold ? 'bold ' : '') + fontSize + "px " + this.fontOptions.face;
ctx.fillStyle = fontColor; ctx.fillStyle = fontColor;
// When the shape is a box and the textAlign property is 'left', make label left-justified
if (this.options.shape === 'box' && this.options.font.textAlign === 'left') {
ctx.textAlign = 'left';
// When the textAlign property is 'left', make label left-justified
if (this.options.font.textAlign === 'left') {
ctx.textAlign = this.options.font.textAlign;
x = x - (this.size.wideth >> 1); // Shift label 1/2-way (>>1 == div by 2) left x = x - (this.size.wideth >> 1); // Shift label 1/2-way (>>1 == div by 2) left
} else { } else {
ctx.textAlign = 'center'; ctx.textAlign = 'center';

Loading…
Cancel
Save