GUI -- Fixed empty or null label issue (cycle labels)
- use Math.floor on [x,y] coords sent to server. Change-Id: I81940892cb11e14c207e0e153425513022cef669
Showing
1 changed file
with
9 additions
and
10 deletions
| ... | @@ -212,13 +212,18 @@ | ... | @@ -212,13 +212,18 @@ |
| 212 | 212 | ||
| 213 | function cycleLabels() { | 213 | function cycleLabels() { |
| 214 | labelIdx = (labelIdx === network.deviceLabelCount - 1) ? 0 : labelIdx + 1; | 214 | labelIdx = (labelIdx === network.deviceLabelCount - 1) ? 0 : labelIdx + 1; |
| 215 | + | ||
| 216 | + function niceLabel(label) { | ||
| 217 | + return (label && label.trim()) ? label : '.'; | ||
| 218 | + } | ||
| 219 | + | ||
| 215 | network.nodes.forEach(function (d) { | 220 | network.nodes.forEach(function (d) { |
| 216 | var idx = (labelIdx < d.labels.length) ? labelIdx : 0, | 221 | var idx = (labelIdx < d.labels.length) ? labelIdx : 0, |
| 217 | node = d3.select('#' + safeId(d.id)), | 222 | node = d3.select('#' + safeId(d.id)), |
| 218 | box; | 223 | box; |
| 219 | 224 | ||
| 220 | node.select('text') | 225 | node.select('text') |
| 221 | - .text(d.labels[idx]) | 226 | + .text(niceLabel(d.labels[idx])) |
| 222 | .style('opacity', 0) | 227 | .style('opacity', 0) |
| 223 | .transition() | 228 | .transition() |
| 224 | .style('opacity', 1); | 229 | .style('opacity', 1); |
| ... | @@ -684,13 +689,7 @@ | ... | @@ -684,13 +689,7 @@ |
| 684 | deselectAll(); | 689 | deselectAll(); |
| 685 | } | 690 | } |
| 686 | 691 | ||
| 687 | - // TODO: allow for mutli selections | 692 | + selections[obj.id] = { obj: obj, el : el}; |
| 688 | - var selected = { | ||
| 689 | - obj : obj, | ||
| 690 | - el : el | ||
| 691 | - }; | ||
| 692 | - | ||
| 693 | - selections[obj.id] = selected; | ||
| 694 | selectOrder.push(obj.id); | 693 | selectOrder.push(obj.id); |
| 695 | 694 | ||
| 696 | n.classed('selected', true); | 695 | n.classed('selected', true); |
| ... | @@ -797,8 +796,8 @@ | ... | @@ -797,8 +796,8 @@ |
| 797 | sendMessage('updateMeta', { | 796 | sendMessage('updateMeta', { |
| 798 | id: d.id, | 797 | id: d.id, |
| 799 | 'class': d.class, | 798 | 'class': d.class, |
| 800 | - x: d.x, | 799 | + x: Math.floor(d.x), |
| 801 | - y: d.y | 800 | + y: Math.floor(d.y) |
| 802 | }); | 801 | }); |
| 803 | } | 802 | } |
| 804 | 803 | ... | ... |
-
Please register or login to post a comment