1

From the example of c3.js, a scatterplot is generated by

data: {
    x: 'setosa_x',
    columns: [
        ["setosa_x", ...SOME DATA...],
        ["setosa", ...SOME OTHER DATA...],
    ],
    type: 'scatter'
},

and google and stackoverflow taught me that i can change the radius of bubbles of scatterplot with this manner:

point: {
    r: function(d) { // <- d has x, value, and index
        return d.x+d.value+d.index;
    }
}

in this way, i can access all information (x, value, index) given the data column has only x and value data for changing the radius. But I'd like to append additional data for the radius, and access the data via this radius function r: function(d) {}. Thanks in advance!

Community
  • 1
  • 1
Leonard2
  • 894
  • 8
  • 21

1 Answers1

3

Do you mean like this?

var otherData = [17, 11, 4, 8, 12, 34]

var chart = c3.generate({
    data: {
        columns: [
            ['data1', 30, 200, 100, 400, 150, 250],
            ['data2', 50, 20, 10, 40, 15, 25]
        ],
        type: 'scatter',

    },
    point: {
        r: function(d) { return otherData[d.index]; },
    }
});
mgraham
  • 6,147
  • 1
  • 21
  • 20
  • though `otherData` is not involved in the c3 structure, this is brilliant. this helps a lot and thanks for the answer. – Leonard2 Aug 19 '16 at 06:50
  • +1 @mgraham, here using other dataset we are setting the radius. but how will we scale it for x or y axis - i mean using scale function – sureshd May 10 '17 at 14:59