Search code examples
c3

Scatter plot size on "tooltip"


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


Solution

  • 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/