Я пытаюсь изменить всплывающую подсказку в техническом радаре Заландо .
Соответствующий код:
function showBubble(d) {
if (d.active || config.print_layout) {
var tooltip = d3.select("#bubble text")
.text(d.label);
var bbox = tooltip.node().getBBox();
d3.select("#bubble")
.attr("transform", translate(d.x - bbox.width / 2, d.y - 16))
.style("opacity", 0.8);
d3.select("#bubble rect")
.attr("x", -5)
.attr("y", -bbox.height)
.attr("width", bbox.width + 10)
.attr("height", bbox.height + 4);
d3.select("#bubble path")
.attr("transform", translate(bbox.width / 2 - 5, 3));
}
}
Чтобы расширить всплывающую подсказку, которую я пыталсяделать следующее на основе решения , описанного здесь .
Мой измененный код:
function showBubble(d) {
if (d.active || config.print_layout) {
var tooltip = d3.select("#bubble text");
tooltip.html("foo"); // this works!
//tooltip.html(function(d) { d.label}) // d is undefinded here ...
tooltip.append("div").attr("id", "foo");
d3.select("#foo").html("This is not shown").attr("style", "block");
var bbox = tooltip.node().getBBox();
d3.select("#bubble")
.attr("transform", translate(d.x - bbox.width / 2, d.y - 16))
.style("opacity", 0.8);
d3.select("#bubble rect")
.attr("x", -5)
.attr("y", -bbox.height)
.attr("width", bbox.width + 10)
.attr("height", bbox.height + 4);
d3.select("#bubble path")
.attr("transform", translate(bbox.width / 2 - 5, 3));
}
}
Может кто-нибудь дать мне подсказку, как показать этот дополнительный текст?
обновление
полный код https://github.com/zalando/tech-radar