问题
How to retrieve the radius(or size) of a scatter plot on tooltip.
r : function(d) {
if (d.value != null) {
var size = datajson[k++]["total"];
return size;
}
I have done something like this..So the tooltip should show the size when i point on that bubble. How to achieve this?
thanks
回答1:
You can add the size to the d object
r: function (d) {
if (d.value != null) {
var size = datajson[k++]["total"];
d.size = size;
return size;
}
}
and retrieve it when you show your tooltip
tooltip: {
contents: function (d) {
if (d[0].value != null) {
return d[0].size;
}
}
},
Fiddle - http://jsfiddle.net/f0cotcqp/
来源:https://stackoverflow.com/questions/30936352/scatter-plot-size-on-tooltip