Scatter plot size on “tooltip”

僤鯓⒐⒋嵵緔 提交于 2019-12-13 05:49:47

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!