dpid label popups. various tweaks.
diff --git a/web/ons-demo/js/map.js b/web/ons-demo/js/map.js
index 382cb26..d40c9cb 100644
--- a/web/ons-demo/js/map.js
+++ b/web/ons-demo/js/map.js
@@ -116,7 +116,7 @@
});
}
-function updateLinkLines() {
+function drawLinkLines() {
// key on link dpids since these will come/go during demo
var linkLines = linksLayer.selectAll('.link').data(links, function (d) {
@@ -227,12 +227,36 @@
if (d.label) {
g.append('svg:text')
+ .classed('label', true)
.text(d.label)
- .attr('x', d.x + width)
- .attr('y', d.y + width);
+ .attr("text-anchor", "end")
+ .attr('x', d.x - width)
+ .attr('y', d.y - width);
}
}
+function labelsEnter(switches) {
+ return labelsLayer.selectAll('g').data(switches, function (d) {
+ return d.dpid;
+ }).enter().append('svg:g')
+ .classed('nolabel', true)
+ .attr("id", function (data) {
+ return data.dpid + '-label';
+ })
+ .append("svg:text")
+ .text(function (data) {return data.dpid;})
+ .attr('x', function (d) {
+ return d.x;
+ })
+ .attr('y', function (d) {
+ return d.y;
+ })
+ .attr("text-anchor", function (d) {
+ return d.x > 500 ? "end" : "start";
+ })
+
+}
+
function switchesEnter(switches) {
return switchLayer.selectAll('g').data(switches, function (d) {
return d.dpid;
@@ -251,29 +275,6 @@
.each(switchEnter);
}
-// function labelsEnter(className, model) {
-// .enter().append("svg:g")
-// .classed('nolabel', true)
-// .attr("id", function (data) {
-// return data.dpid + '-label';
-// })
-
-
-// return topology.selectAll('.'+className).data(makeSwitchesModel(model))
-// .enter()
-// .append('svg:g')
-// .attr("id", function (d) {
-// return d.dpid;
-// })
-// .classed('core', true)
-// .attr('x', function (d) {
-// return d.x;
-// })
-// .attr('y', function (d) {
-// return d.y;
-// })
-// .each(switchEnter);
-// }
function switchesUpdate(switches) {
switches.each(function (d) {
@@ -307,11 +308,9 @@
switchesUpdate(switchesEnter(switches));
+ drawLinkLines();
-
-
-
- updateLinkLines();
+ labelsEnter(switches);
}
})();
\ No newline at end of file