问题描述
var nodeEnter = node.enter().append("g")
.attr("class", "node")
.attr("transform", function(d) { return "translate(" + source.y0 + "," + source.x0 + ")"; })
.on("click", click)
.on("mouseover",function (d){
if(d.name=="Purchased"){
jQuery.getJSON("RequestHandler?usercommand=jsoncompany&subcommand=propCount&useraction=d3Tree_frm&mgmtId="+d.id+"&type="+d.name, function(json){
var count=JSON.stringify(json.prop_purchased_count);
result="Purchased Property :"+count;
});
}
var g = d3.select(this);
var info = g.append("text")
.classed('info', true)
.attr('x', 30)
.attr('y', 30)
.text(result); //result="Amount":200\n"Amount":300\n"Amount":400
})
.on("mouseout", function() {
d3.select(this).select('text.info').remove();
});
//result =数量":200 \ n数量":300 \ n数量":400
我想显示工具提示,使其在\ n之后出现在该工具提示的新行中.
//result="Amount":200\n"Amount":300\n"Amount":400
i want to display tooltip such that after \n it appears in a new line within that tooltip.
如何实现?
预先感谢
推荐答案
我可以看到在您发布的代码中设置了result
,但是我们看不到的是设置了result
来获取您所要内容的位置说"它包含.这样,我们可以帮助您更好地解释这些行之有效的建议的应用.但是无论如何,请查看这些资源以帮助您完成任务.
I can see result
being set in the code you posted, however what we cannot see is where result
is being set to get the content you are 'saying' it contains. That way we could help you interpret the application of these proven recommendations a lot better. But in anycase, have a look at these resources to help you in your quest.
http://bl.ocks.org/mbostock/7555321
这篇关于d3节点工具提示值多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!