Skip to content

Instantly share code, notes, and snippets.

@diegoy
Last active August 29, 2015 14:22
Show Gist options
  • Save diegoy/279d34dad8faf6d639da to your computer and use it in GitHub Desktop.
Save diegoy/279d34dad8faf6d639da to your computer and use it in GitHub Desktop.
C3.js using json data to populate x axis
//http://jsfiddle.net/r0hydxpb/2/
var chart = c3.generate({
data:{
json:[
{"key":2000,"value":100},{"key":2001,"value":200},
{"key":2003,"value":300},{"key":2004,"value":400},
{"key":2005,"value":500},{"key":2006,"value":600},
{"key":2007,"value":700}
],
keys:{
x: 'key',
value:['value']
}
},
axis: {
x: {
x:['key'],
type: "category"
}
}
});
//alert(chart.data('key')[0]);
console.log(chart.data('key')[0].values[3].value)
console.log(chart.data('value')[0].values[3].value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment