Commit 645a034e authored by Masayuki Tanaka's avatar Masayuki Tanaka

Fix loading json with undefined data - #325

parent a7cc082d
......@@ -1499,7 +1499,9 @@
json.forEach(function (o) {
var new_row = [];
targetKeys.forEach(function (key) {
new_row.push(o[key]);
// convert undefined to null becuase undefined data will be removed in convertDataToTargets()
var v = typeof o[key] === 'undefined' ? null : o[key];
new_row.push(v);
});
new_rows.push(new_row);
});
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -5,6 +5,7 @@
<body>
<div id="chart1"></div>
<div id="chart2"></div>
<div id="chart3"></div>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="/js/c3.js"></script>
......@@ -43,6 +44,33 @@
}
});
var chart3 = c3.generate({
bindto: '#chart3',
data: {
json: [{
"date": "2014-06-03",
"443": "3000",
"995": "500"
}, {
"date": "2014-06-04",
"443": "1000",
}, {
"date": "2014-06-05",
"443": "5000",
"995": "1000"
}],
keys: {
x: 'date',
value: [ "443", "995" ]
}
},
axis: {
x: {
type: "category"
}
}
});
</script>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment