D3 interactive line graph dataset values reversed - d3.js

I have a line d3.js line graph pictured below:
Two oddities. First notice the vertical mouse line. Notice the hover line at the green line. The data entry 72.3.... is not correct for that date. It is the correct value near 0 on the x axis. The text data is basically reversed to the timeScale(). The green line is plotted correctly.
Second, why does the green line apeear to have shadows? The code for the hover line is below:
var enableMouseOver = function () {
mouseG = chart.append("svg:g")
.attr("class", "mouse-over-effects");
//Vertical line from height to y0
mouseG.append("path")
.attr("class", containerId + "-mouse-line")
.style("stroke", "black")
.style("stroke-width", "1px")
.style("opacity", "0");
lines = document.getElementsByClassName(containerId + "-line");
mousePerLine = mouseG.selectAll('.' + containerId + '-mouse-per-line')
.data(dataset)
.enter()
.append("g")
.attr("class", containerId + '-mouse-per-line');
/*
mousePerLine.append("circle")
.attr("r", 7)
.style("stroke", "black")
.style("fill", "none")
.style("opacity", "0");
*/
mousePerLine.append("text")
.attr("transform", "translate(10,3)");
mouseG.append("svg:rect")
.attr('width', width)
.attr('height', height)
.attr('fill', 'none')
.attr('pointer-events', 'all')
.on("mouseout", function () {
d3.select("." + containerId + "-mouse-line")
.style("opacity", "0");
//d3.selectAll("." + containerId + "-mouse-per-line circle")
// .style("opacity", "0");
d3.selectAll("." + containerId + "-mouse-per-line text")
.style("opacity", "0");
})
.on("mouseover", function () {
d3.select("." + containerId + "-mouse-line")
.style("opacity", "1");
//d3.selectAll("." + containerId + "-mouse-per-line circle")
// .style("opacity", "1");
d3.selectAll("." + containerId + "-mouse-per-line text")
.style("opacity", "1");
})
.on("mousemove", function () {
var mouse = d3.mouse(this);
d3.select("." + containerId + "-mouse-line")
.attr("d", function () {
var d = "M" + mouse[0] + "," + height;
d += " " + mouse[0] + "," + 0;
return d;
});
d3.selectAll("." + containerId + "-mouse-per-line")
.attr("transform", function (d, i) {
var xDate = xScale.invert(mouse[0]),
bisect = d3.bisector(function (d) {
return d.date;
}).right;
var idx = bisect(d.available, xDate);
var beginning = 0,
end = lines[i].getTotalLength(),
target = null;
while (true) {
var pos = lines[i].getPointAtLength(target);
if ((target === end || target === beginning) && pos.x !== mouse[0]) {
break;
}
else if (pos.x > mouse[0]) beginning = target;
else break;
}
var displayFormat;
if (interval === 'weekly' || interval === 'monthly') {
displayFormat = d3.timeFormat("%m/%d");
}
else {
displayFormat = d3.timeFormat("%H:%M:%S");
}
d3.select(this).select('text')
.text(displayFormat(xDate) + " " + yScale.invert(pos.y).toFixed(4))
.attr("font-size", ".5em");
if (i === 1 && (interval === 'daily' || interval === 'hourly')) {
return "translate(" + (mouse[0] - 80) + "," + pos.y + ")";
}
else if (i === 1 && (interval === 'weekly' || interval === 'monthly')) {
return "translate(" + (mouse[0] - 65) + "," + pos.y + ")";
}
else {return "translate(" + mouse[0] + "," + pos.y + ")";}
});
});
}
Thanks in advance!

Related

Lost flow chart lines after upgrading from 3.5.5 to 4.2.8

After upgrading from 3.5.5 to 4.2.8 the flow chart lines connecting steps (represented by boxes) forward progression are gone, while lines to previous steps remain.
What needs to be changed to restore the lines?
This is the code that creates the flow chart.
function VisualizeIt(selectedItem) {
// dataset created using error handling if the data doesn't load it will say why in the console
// the text file contains all the json for the entire tree
d3.json("withdrawal.json", function (error, json) {
if (error) {
console.log(error);
}
else //it worked, so continue with the visualization
{
result = []; //clear the array
resultChildren = []; //clear the array
// grab the result and the child steps from the data
// this fills the above arrays with data
find(json, selectedItem);
//grab the parent of the selected item to display in the left hand box
resultParent = []; //clear the array
// this fills the last array with data
findParent(json, result[0].parentId);
// PARENT step
var parentStep = svg.select('.resultParent').selectAll("rect")
.data(resultParent, function (d) { return d.id; });
parentStep.enter().append("rect")
.attr("x", ParentStepPosition(resultChildren.length)[0])
.attr("y", ParentStepPosition(resultChildren.length)[1])
.attr("width", ParentStepSize(resultChildren.length))
.attr("height", ParentStepSize(resultChildren.length))
.attr("fill", "#003f87")
.attr("onclick", "VisualizeIt(" + result[0].parentId + ")");
parentStep.exit().remove();
var parentStepText = svg.select('.resultParent').selectAll("g")
.data(resultParent, function (d) { return d.id; });
parentStepText
.enter()
.append("g")
.append(function (d, i) {
//console.log("textHeight: " + textHeight + ", lineCount :" + lineCount);
textHeight = 0;
var svgText = createSVGtext("Step Back"
, ParentStepPosition(resultChildren.length)[0] + (ParentStepSize(resultChildren.length) / 2)
, ParentStepPosition(resultChildren.length)[1] + ((ParentStepSize(resultChildren.length) ) / 2) + 4
);
//console.log("textHeight: " + textHeight + ", lineCount :" + lineCount);
return svgText;
})
.attr("font-family", "sans-serif")
.attr("font-size", "12px")
.attr("fill", "white")
.attr("text-anchor", "middle")
.attr("onclick", "VisualizeIt(" + result[0].parentId + ")");
;
parentStepText.exit().remove();
//child connectors
var parentStepLines = svg.select(".result").selectAll("path")
.data( resultParent , function (d) { return d.id; });
// parent steps Lines
parentStepLines
.enter()
.append("path")
.attr("d", function (d, i) {
// format: M 100 350 q 150 -300 300 0
// format: M startPointX startPointY q
var startPointX = ParentStepPosition(resultChildren.length)[0] + ParentStepSize(resultChildren.length); // far right side of the selected
var startPointY = ParentStepPosition(resultChildren.length)[1] + (ParentStepSize(resultChildren.length) / 2); //half the height of the selected
var midPointX = ParentStepPosition(resultChildren.length)[0] + ParentStepSize(resultChildren.length); // far right side of the selected
var midPointY = SelectedStepPosition()[1] + SelectedStepSize() / 2;
var endPointX = SelectedStepPosition()[0];
var endPointY = SelectedStepPosition()[1] + SelectedStepSize() / 2;
return "M" + " " + startPointX + " " + startPointY + " Q " + midPointX + " " + midPointY + " " + endPointX + " " + endPointY;
})
.style("stroke", "#0083d6")
.style("stroke-width", "5")
.style("fill", "none");
parentStepLines.exit().remove();
// CURRENT step
var currentStep = svg.select(".result").selectAll("rect")
.data(result, function (d) { return d.id; });
currentStep.enter().append("rect")
.attr("x", SelectedStepPosition()[0])
.attr("y", SelectedStepPosition()[1])
.attr("width", SelectedStepSize())
.attr("height", SelectedStepSize())
.attr("fill", "#003f87")
.attr("onclick", "")
.text(function (d) { return "id: " + d.id });
currentStep.exit().remove();
var currentStepText = svg.select(".result").selectAll("g")
.data(result, function (d) { return d.id; });
// current step text
currentStepText
.enter()
.append("g")
.append(function (d, i) {
//console.log("textHeight: " + textHeight + ", lineCount :" + lineCount);
textHeight = 0;
var svgText = createSVGtext(d.title
, SelectedStepPosition()[0] + (SelectedStepSize() / 2)
, SelectedStepPosition()[1] + ((SelectedStepSize() - TextHeight(d.title)) / 2) + 4
);
//console.log("textHeight: " + textHeight + ", lineCount :" + lineCount);
return svgText;
})
.attr("font-family", "sans-serif")
.attr("font-size", "12px")
.attr("fill", "white")
.attr("text-anchor", "middle");
currentStepText.exit().remove();
// CHILDREN
// i.e. next available steps
// use the ID as the key when linking the data
var childrenSteps = d3.select(".resultChildren").selectAll("rect")
.data(resultChildren, function (d) { return d.id; });
childrenSteps
.enter()
.append("rect")
.attr("x", function (d, i) { return ChildStepPosition(i, resultChildren.length)[0]; })
.attr("y", function (d, i) { return ChildStepPosition(i, resultChildren.length)[1]; })
.attr("width", SelectedChildStepSize(resultChildren.length)[1])
.attr("height", SelectedChildStepSize(resultChildren.length)[0])
.attr("fill", "#003f87")
.attr("onclick", function (d, i) { return 'VisualizeIt(' + d.id + ')';})
.text(function (d) { return "id: " + d.id });
childrenSteps.exit().remove();
var childrenStepsText = svg.select(".resultChildren").selectAll("g")
.data(resultChildren, function (d) { return d.id; });
// children steps text
childrenStepsText
.enter()
.append("g")
.append(function (d, i) {
//console.log("textHeight: " + textHeight + ", lineCount :" + lineCount);
textHeight = 0;
var svgText = createSVGtext(d.asChildText
, ChildStepPosition(i, resultChildren.length)[0] + (SelectedChildStepSize(resultChildren.length)[1] / 2)
, ChildStepPosition(i, resultChildren.length)[1] + ((SelectedChildStepSize(resultChildren.length)[0] - TextHeight(d.asChildText)) / 2) +4
);
//console.log("textHeight: " + textHeight + ", lineCount :" + lineCount);
return svgText;
})
.attr("font-family", "sans-serif")
.attr("font-size", "12px")
.attr("fill", "white")
.attr("text-anchor", "middle")
.attr("onclick", function (d, i) { return 'VisualizeIt(' + d.id + ')'; });
;
childrenStepsText.exit().remove();
var lineFunction = d3.svg.line();
//child connectors
var childrenStepLines = svg.select(".resultChildren").selectAll("path")
.data(resultChildren, function (d) { return d.id; });
// children steps Lines
childrenStepLines
.enter()
.append("path")
.attr("d", function (d, i) {
// format: M 100 350 q 150 -300 300 0
// format: M startPointX startPointY q
var startPointX = SelectedStepPosition()[0] + SelectedStepSize(); // far right side of the selected
var startPointY = SelectedStepPosition()[1] + (SelectedStepSize() / 2); //half the height of the selected
var midPointX = SelectedStepPosition()[0] + SelectedStepSize(); // far right side of the selected
var midPointY = ChildStepPosition(i, resultChildren.length)[1] + SelectedChildStepSize(resultChildren.length)[0] / 2;
var endPointX = ChildStepPosition()[0];
var endPointY = ChildStepPosition(i, resultChildren.length)[1] + SelectedChildStepSize(resultChildren.length)[0] / 2;
return "M" + " " + startPointX + " " + startPointY + " Q " + midPointX + " " + midPointY + " " + endPointX + " " + endPointY;
})
.style("stroke", "#0083d6")
.style("stroke-width", "5")
.style("fill", "none");
childrenStepLines.exit().remove();
//update the iframe with the correct detailed html
d3.select("iframe").attr("src", "iFrameHTML/" + result[0].url);
};
});
};
thanks
The code was throwing an error at line 250.
TypeError: d3.svg is undefined
var lineFunction = d3.svg.line();
Version 3.5.5 let the error slide. In version 4.2.8 it did not let the error slide.
Once I commented out line 250, the child step line displayed. I do not know the purpose of line 250. a prvious programmer created it. There is no reference in the entire code to a variable called lineFunction.

Bubble chart align center d3 js

I have created a bubble chart with zoom feature on JSfiddle
var r = 500,
h = 500,
format = d3.format(",d"),
fill = d3.scale.category20c();
var bubble = d3.layout.pack().sort(null).size([r,h]);
var vis = d3.select("#chart").append("svg")
.attr("class", "bubble")
.call(d3.behavior.zoom().on("zoom", redraw))
.append("g").attr("class", "group2")
d3.json("cantGetRidOfThis", function() {
var node = vis.selectAll("g.node")
.data(bubble.nodes(flat).filter(function(d) {return !d.children;}))
.enter().append("g")
.attr("class", "node")
.attr("transform", function(d) {return "translate(" + d.x + "," + d.y + ")";});
node.append("title").text(function(d) {return d.className + ": " + format(d.value);});
node.append("circle")
.attr("r", function(d) {return d.r;})
.attr("class", "nodecircle")
.style("fill", '#ff4719')
.attr("data-classname", function(d) {return d.className;});
node.append("text")
.attr("text-anchor", "middle")
.attr("class", "nodetext")
.attr("data-classname", function(d) {return d.className;})
.attr("style", function(d) {return "font-size:" + d.r/5;})
.attr("data-classname", function(d) {return d.className;})
.each(function(d, i) {
var nm = d.className;
var arr = nm.replace(/[\(\)\\/,-]/g, " ").replace(/\s+/g, " ").split(" "),arrlength = (arr.length > 7) ? 8 : arr.length;
d3.select(this).attr('y',"-" + (arrlength/2) + "em");
//if text is over 7 words then ellipse the 8th
for(var n = 0; n < arrlength; n++) {
var tsp = d3.select(this).append('tspan').attr("x", "0").attr("dy", "1em").attr("data-classname", nm);
if(n === 7) {
tsp.text("...");
} else {
tsp.text(arr[n]);
}
}
});
});
function clickOnCircleFunc(el){
var selection = el.target.__data__.className;
//bubble select
$('.nodecircle').each(function (id, v) {
var $this = $(this),d_nm = $this.attr('data-classname');
if (d_nm === selection && $this.attr('data-selected') !== 'y') {
$this.attr('data-selected','y').css('fill', '#3182bd');
}
else {
$this.attr('data-selected','n').css('fill', '#ff4719');
}
});
}
function redraw() {
vis.attr("transform", "translate(" + d3.event.translate + ")" + " scale(" + d3.event.scale + ")");
}
Above code is working fine with all what needed but one thing which am not able to figure out is to populate the chart in centre of the div id="chart".Currently chart is displayed on left .
How can the chart be populate in centre of the div

Drill down pie chart disappears

I make a drill down pie chart and it works well.
You can see it here.
But there is an issue:
1) click a node then it shows its children (level 1) or level 0 nodes.
2) Move mouse to another position and move back to the new node which contains its original position, the node disappears.
I think there is problem in this code (gradientPie.js)
var paths = gPie.selectAll("path").data(pieChart(currData), function(d) {return d.data.cat;});
var texts = gPie.selectAll("text").data(pieChart(currData), function(d) {return d.data.cat;});
var lines = gPie.selectAll("line").data(pieChart(currData), function(d) {return d.data.cat;});
var arcs = paths.enter().append("g").attr('class', 'slice');
arcs.append("path").attr("fill", function(d, i) { return "url(#gradient" + d.data.cat + ")"; })
.transition().duration(1000).attrTween("d", tweenIn).each("end", function(){
this._listenToEvents = true;
gradPie.transitioning = false;
})
.attr("id", function(d, i){return 'p' + i;})
.each(function(d) { this._current = d; });
arcs.append("text").attr("transform", function(d) {
var c = d3.svg.arc().outerRadius(radius * 1.4).innerRadius(radius).centroid(d);
return "translate(" + (0 + c[0]) + "," + (0 + c[1]) + ")";
})
.attr("dy", ".35em")
.attr("class", "text-main")
.style("text-anchor", "middle")
.style("fill", "#3f5763")
.style("font", "bold 14px Helvetica")
.text(function(d) {
$("#" + d.data.domID + " p").html(d.data.percent + "%");
return d.data.percent + "%";
});
arcs.append("line").attr("transform", function (d, i) {
var rAngle = ((d.startAngle + d.endAngle) / 2 - (Math.PI / 2)) * 180 / Math.PI;
return "rotate(" + rAngle + ")translate(" + radius * 1.1 + ")";
})
.attr("class", "line-ticks")
.attr('stroke-width', '1')
.attr("x2", -0.5 * radius)
.style("stroke", "#3f5763")
.style("fill", "none");
// Mouse interaction handling
paths.on("click", function(d, i){
if(this.childNodes[0]._listenToEvents && !gradPie.transitioning){
// Reset inmediatelly
d3.select(this).attr("transform", "translate(0,0)")
// Change level on click if no transition has started
paths.each(function(){
this.childNodes[0]._listenToEvents = false;
});
updateGraph(d.data.subfractions? d.data.cat : undefined);
}
})
.on("mouseover", function(d, i){
// Mouseover effect if no transition has started
if(this.childNodes[0]._listenToEvents && !gradPie.transitioning) {
// Calculate angle bisector
var ang = (d.endAngle + d.startAngle)/2;
// Transformate to SVG space
ang = (ang - (Math.PI / 2) ) * -1;
// Calculate a 10% radius displacement
var x = Math.cos(ang) * radius * 0.1;
var y = Math.sin(ang) * radius * -0.1;
d3.select(this).transition()
.duration(250).attr("transform", function() {
return "translate(" + x + ", " + y + ")";
})
}
})
.on("mouseout", function(d){
// Mouseout effect if no transition has started
if(this.childNodes[0]._listenToEvents && !gradPie.transitioning){
d3.select(this).transition()
.duration(150).attr("transform", function() {
return "translate(0,0)";
});
}
});
// Collapse sectors for the exit selection
paths.exit().transition()
.duration(1000)
.attrTween("d", tweenOut).remove();
texts.exit().transition()
.duration(100).remove();
lines.exit().transition()
.duration(100).remove();
Any help?

display different image of each node on mobile suite example of d3

How to display each node of different image. I show an example of d3 on github. but in this there is only one links.
How to display each node a different image. Any solution?
This is my example.
var nodes = {};
// Compute the distinct nodes from the links.
links.forEach(function(link) {
link.source = nodes[link.source] || (nodes[link.source] = {name: link.source});
link.target = nodes[link.target] || (nodes[link.target] = {name: link.target});
});
var width = 900,
height = 900;
var force = d3.layout.force()
.nodes(d3.values(nodes))
.links(links)
.size([width, height])
.linkDistance(90)
.charge(-600)
.on("tick", tick)
.start(type, crawledPageID);
var svg = d3.select("#d3Graph").append("svg")
.attr("width", width)
.attr("height", height).call(zoom);
// Per-type markers, as they don't inherit styles.
svg.append("defs").selectAll("marker")
.data(["suit", "licensing", "resolved"])
.enter().append("marker")
.attr("id", function(d) { return d; })
.attr("viewBox", "0 -5 10 10")
.attr("refX", 15)
.attr("refY", -1.5)
.attr("markerWidth", 6)
.attr("markerHeight", 6)
.attr("orient", "auto")
.append("path")
.attr("d", "M0,-5L10,0L0,5");
var path = svg.append("g").selectAll("path")
.data(force.links())
.enter().append("path")
.attr("class", function(d) { return "link " + d.type; })
.attr("marker-end", function(d) { return "url(#" + d.type + ")"; });
var circle = svg.append("g").selectAll("circle")
.data(force.nodes())
.enter().append("circle")
.attr("r", 3)
.call(force.drag);
var text = svg.append("g").selectAll("text")
.data(force.nodes())
.enter().append("text")
.attr("x", 6)
.attr("y", ".21em")
.text(function(d) {return d.name; });
var edgeText = svg.append("svg:g").selectAll("path")
.data(force.links())
.enter().append("svg:path")
.attr("id", function(d) { return d.source.index + "_" + d.target.index; })
.attr("class", function(d) { return "link " + d.type; })
.attr("marker-end", function(d) { return "url(#" + d.type + ")"; });
var path_label = svg.append("svg:g").selectAll(".path_label")
.data(force.links())
.enter().append("svg:text")
.attr("class", "path_label")
.append("svg:textPath")
.attr("startOffset", "50%")
.attr("text-anchor", "middle")
.attr("xlink:href", function(d) { return "#" + d.source.index + "_" + d.target.index; })
.style("fill", "#000")//edge color
.style("font-size","10px")
.style("font-family", "Serif")
.text(function displayNote(d){ return "";// d.rel;
});
/**
function displayNote(){
var chkStatus1 = document.getElementById("door2");
if (chkStatus1.checked)
{
return d.rel;
}
else
{
return "----";
}
} *
*
*/
// Use elliptical arc path segments to doubly-encode directionality.
function tick()
{
circle.attr("transform", transform);
text.attr("transform", transform);
edgeText.attr("d", function(d) {
var dx = d.target.x - d.source.x,
dy = d.target.y - d.source.y,
dr = 0;//Math.sqrt(dx * dx + dy * dy);
return "M" +
d.source.x + "," +
d.source.y + "A" +
dr + "," + dr + " 0 0,1 " +
d.target.x + "," +
d.target.y;
});
}
/*function linkArc(d) {
var dx = d.target.x - d.source.x,
dy = d.target.y - d.source.y,
dr = Math.sqrt(dx * dx + dy * dy);
return "M" + d.source.x + "," + d.source.y + "A" + dr + "," + dr + " 0 0,1 " + d.target.x + "," + d.target.y;
}*/
function transform(d)
{
return "translate(" + d.x + "," + d.y + ")";
}

cannot show tooltip on rotating cluster layout

I have not been able to show the tooltip for this graph:
http://mbostock.github.io/d3/talk/20111018/cluster.html
I have tried the simplest way without success:
node.append("svg:title").text(function(d) { return d.key; });
And also tried this without success:
var div = d3.select("body").append("div").attr("class", "tooltip")
.style("opacity", 0);
node.append("svg:circle")
.attr("r", 3)
.on("mouseover", function (d) {
div.transition()
.duration(0)
div.style("opacity", 1)
div.html(d.key)
.style("width", d.key.length + "mm")
.style("left", (d3.event.pageX) + "px")
.style("top", (d3.event.pageY - 28) + "px");
})
.on("mouseout", function (d) {
div.transition()
.duration(0)
.style("opacity", 0);
});
Here is the complete code:
var w = 1280,
h = 800,
rx = w / 2,
ry = h / 2,
m0,
rotate = 0;
var cluster = d3.layout.cluster()
.size([360, ry - 120])
.sort(null);
var diagonal = d3.svg.diagonal.radial()
.projection(function (d) {
return [d.y, d.x / 180 * Math.PI];
});
var svg = d3.select("body").append("div")
.style("width", w + "px")
.style("height", w + "px");
var vis = svg.append("svg:svg")
.attr("width", w)
.attr("height", w)
.append("svg:g")
.attr("transform", "translate(" + rx + "," + ry + ")");
vis.append("svg:path")
.attr("class", "arc")
.attr("d", d3.svg.arc().innerRadius(ry - 120).outerRadius(ry).startAngle(0).endAngle(2 * Math.PI))
.on("mousedown", mousedown);
var div = d3.select("body").append("div").attr("class", "tooltip")
.style("opacity", 0);
function drawNodes(graph) {
var nodes = cluster.nodes(graph);
var link = vis.selectAll("path.link")
.data(cluster.links(nodes))
.enter().append("svg:path")
.attr("class", "link")
.attr("d", diagonal);
var node = vis.selectAll("g.node")
.data(nodes)
.enter().append("svg:g")
.attr("class", "node")
.attr("transform", function (d) {
return "rotate(" + (d.x - 90) + ")translate(" + d.y + ")";
})
node.append("svg:circle")
.attr("r", 3)
.on("mouseover", function (d) {
div.transition()
.duration(0)
div.style("opacity", 1)
div.html(/*"info:" + "<br/>" + */d.key)
.style("width", d.key.length + "mm")
//.style("height", "10mm") ???
.style("left", (d3.event.pageX) + "px")
.style("top", (d3.event.pageY - 28) + "px");
})
.on("mouseout", function (d) {
div.transition()
.duration(0)
.style("opacity", 0);
});
node.append("svg:text")
.attr("dx", function (d) {
return d.x < 180 ? 8 : -8;
})
.attr("dy", ".31em")
.attr("text-anchor", function (d) {
return d.x < 180 ? "start" : "end";
})
.attr("transform", function (d) {
return d.x < 180 ? null : "rotate(180)";
})
.text(function (d) {
return d.name;
});
// TODO: does not work...not sure why...mouseover being captured already?
node.append("svg:title")
.text(function(d) { return d.key; });
}
//});
d3.select(window)
.on("mousemove", mousemove)
.on("mouseup", mouseup);
function mouse(e) {
return [e.pageX - rx, e.pageY - ry];
}
function mousedown() {
m0 = mouse(d3.event);
d3.event.preventDefault();
}
function mousemove() {
if (m0) {
var m1 = mouse(d3.event),
dm = Math.atan2(cross(m0, m1), dot(m0, m1)) * 180 / Math.PI,
tx = "translate3d(0," + (ry - rx) + "px,0)rotate3d(0,0,0," + dm + "deg)translate3d(0," + (rx - ry) + "px,0)";
svg.style("-moz-transform", tx)
.style("-ms-transform", tx)
.style("-webkit-transform", tx);
}
}
function mouseup() {
if (m0) {
var m1 = mouse(d3.event),
dm = Math.atan2(cross(m0, m1), dot(m0, m1)) * 180 / Math.PI,
tx = "rotate3d(0,0,0,0deg)";
rotate += dm;
if (rotate > 360) rotate -= 360;
else if (rotate < 0) rotate += 360;
m0 = null;
svg.style("-moz-transform", tx)
.style("-ms-transform", tx)
.style("-webkit-transform", tx);
vis.attr("transform", "translate(" + rx + "," + ry + ")rotate(" + rotate + ")")
.selectAll("g.node text")
.attr("dx", function (d) {
return (d.x + rotate) % 360 < 180 ? 8 : -8;
})
.attr("text-anchor", function (d) {
return (d.x + rotate) % 360 < 180 ? "start" : "end";
})
.attr("transform", function (d) {
return (d.x + rotate) % 360 < 180 ? null : "rotate(180)";
});
}
}
function cross(a, b) {
return a[0] * b[1] - a[1] * b[0];
}
function dot(a, b) {
return a[0] * b[0] + a[1] * b[1];
}
The CSS of the example is preventing the nodes from capturing the pointer and thus from showing the tooltips. If you remove the line
pointer-events: none;
from the CSS for .node, it works fine.

Resources