[英]add tooltip in stacked bar chart D3
Could you please help me in adding tooltip in stacked Bar chart. 您能帮我在堆积的条形图中添加工具提示吗? I have created Fiddle Link 我创建了小提琴链接
i want to add tool tip on each bar chart ie. 我想在每个条形图上添加工具提示,即。 Each bar should show tool tip for each color. 每个栏应显示每种颜色的工具提示。 How can i do that. 我怎样才能做到这一点。
> NA
Thanks in advance 提前致谢
You can append a title
element under each rect
and give it a text value of whatever you want the tooltip to say. 您可以在每个rect
下附加一个title
元素,并给它一个文本值,它是您希望工具提示说的内容。
Here's a related question showing more details: How to add a tooltip to an svg graphic? 这是一个显示更多详细信息的相关问题: 如何在svg图形中添加工具提示?
What exactly you want to show on tool tip? 您想在工具提示上显示什么? Is it data value or some text? 它是数据值还是一些文本?
You can add 你可以加
.append("svg:title")
.text(function(d){
return yourData;
}
});
This function should work for you and put the variable name where you are getting corresponding values of bars. 该函数应该为您工作,并将变量名称放在获取相应条形值的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.