score:2

Accepted answer

so long as "ug" and "wtv" have the same number of elements...

var json = {"ug":["K","M2","M3","M4"],"wtv":[10,20,35,60]};
var pieJson = {};
json.ug.forEach(function (ug, index) {
  pieJson[ug] = json.wtv[index];
});

var chart = c3.generate({
  data: {
    // iris data from R
    json: pieJson,
    type : 'pie',
  }
});

jsfiddle.net/4h4z00g7/


Related Query

More Query from same tag