Leire Aguirre
commited on
Commit
·
834ae60
1
Parent(s):
f7842b8
prevent duplicated tooltips
Browse files- src/memory.js +8 -6
src/memory.js
CHANGED
|
@@ -237,7 +237,9 @@ export function updateGraph() {
|
|
| 237 |
}
|
| 238 |
};
|
| 239 |
|
| 240 |
-
|
|
|
|
|
|
|
| 241 |
.append('div')
|
| 242 |
.attr('id', 'tooltip')
|
| 243 |
.style('opacity', 0)
|
|
@@ -247,7 +249,7 @@ export function updateGraph() {
|
|
| 247 |
.style('font-size', '12px')
|
| 248 |
.style('border-radius', '5px')
|
| 249 |
.style('box-shadow', '0px 0px 5px 0px rgba(0,0,0,0.3)');
|
| 250 |
-
|
| 251 |
|
| 252 |
const cell = svg.selectAll("g")
|
| 253 |
.data(root.descendants())
|
|
@@ -256,13 +258,13 @@ export function updateGraph() {
|
|
| 256 |
.on('mouseover', (event, d) => {
|
| 257 |
const name = d.data.name;
|
| 258 |
const value = formatBytes(d.value);
|
| 259 |
-
tooltip.transition().duration(200).text(`${name}: ${value}`)
|
| 260 |
})
|
| 261 |
.on('mouseout', function() {
|
| 262 |
-
tooltip.style('opacity', 0)
|
| 263 |
})
|
| 264 |
.on('mousemove', function(event) {
|
| 265 |
-
tooltip.style('left', (event.pageX + 10) + 'px').style('top', (event.pageY + 10) + 'px').style('opacity', 1)
|
| 266 |
});
|
| 267 |
|
| 268 |
cell.append("rect")
|
|
@@ -317,7 +319,7 @@ export function updateGraph() {
|
|
| 317 |
.attr("height", 19)
|
| 318 |
.attr("fill", d => color(d))
|
| 319 |
.attr("stroke", '#f3f3f3')
|
| 320 |
-
.attr("stroke-width",
|
| 321 |
|
| 322 |
legend.append("text")
|
| 323 |
.attr("x", 24)
|
|
|
|
| 237 |
}
|
| 238 |
};
|
| 239 |
|
| 240 |
+
|
| 241 |
+
if (d3.select('#tooltip').empty()) {
|
| 242 |
+
d3.select('body')
|
| 243 |
.append('div')
|
| 244 |
.attr('id', 'tooltip')
|
| 245 |
.style('opacity', 0)
|
|
|
|
| 249 |
.style('font-size', '12px')
|
| 250 |
.style('border-radius', '5px')
|
| 251 |
.style('box-shadow', '0px 0px 5px 0px rgba(0,0,0,0.3)');
|
| 252 |
+
}
|
| 253 |
|
| 254 |
const cell = svg.selectAll("g")
|
| 255 |
.data(root.descendants())
|
|
|
|
| 258 |
.on('mouseover', (event, d) => {
|
| 259 |
const name = d.data.name;
|
| 260 |
const value = formatBytes(d.value);
|
| 261 |
+
d3.select('#tooltip').transition().duration(200).text(`${name}: ${value}`)
|
| 262 |
})
|
| 263 |
.on('mouseout', function() {
|
| 264 |
+
d3.select('#tooltip').style('opacity', 0)
|
| 265 |
})
|
| 266 |
.on('mousemove', function(event) {
|
| 267 |
+
d3.select('#tooltip').style('left', (event.pageX + 10) + 'px').style('top', (event.pageY + 10) + 'px').style('opacity', 1)
|
| 268 |
});
|
| 269 |
|
| 270 |
cell.append("rect")
|
|
|
|
| 319 |
.attr("height", 19)
|
| 320 |
.attr("fill", d => color(d))
|
| 321 |
.attr("stroke", '#f3f3f3')
|
| 322 |
+
.attr("stroke-width", 0);
|
| 323 |
|
| 324 |
legend.append("text")
|
| 325 |
.attr("x", 24)
|