Commit 60a43789 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Add xs argument for load interface

parent c0a252e2
...@@ -568,6 +568,11 @@ ...@@ -568,6 +568,11 @@
function getXValue(id, i) { function getXValue(id, i) {
return id in c3.data.x && c3.data.x[id] && c3.data.x[id][i] ? c3.data.x[id][i] : i; return id in c3.data.x && c3.data.x[id] && c3.data.x[id][i] ? c3.data.x[id][i] : i;
} }
function addXs(xs) {
Object.keys(xs).forEach(function (id) {
__data_xs[id] = xs[id];
});
}
function addName(data) { function addName(data) {
var name; var name;
...@@ -617,6 +622,8 @@ ...@@ -617,6 +622,8 @@
var xKey = getXKey(id); var xKey = getXKey(id);
if (xs.indexOf(xKey) >= 0) { if (xs.indexOf(xKey) >= 0) {
c3.data.x[id] = data.map(function (d) { return d[xKey]; }); c3.data.x[id] = data.map(function (d) { return d[xKey]; });
} else { // if no x included, use same x of current will be used
c3.data.x[id] = c3.data.x[Object.keys(c3.data.x)[0]];
} }
}); });
} }
...@@ -2470,9 +2477,13 @@ ...@@ -2470,9 +2477,13 @@
c3.load = function (args) { c3.load = function (args) {
// check args // check args
if (isUndefined(args.done)) { if (typeof args.done !== 'function') {
args.done = function () {}; args.done = function () {};
} }
// update xs if exists
if (args.xs) {
addXs(args.xs);
}
// update categories if exists // update categories if exists
if ('categories' in args && isCategorized) { if ('categories' in args && isCategorized) {
__axis_x_categories = args.categories; __axis_x_categories = args.categories;
......
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