Commit a66beb31 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Fix data.values interface

parent e7f976df
......@@ -6241,12 +6241,16 @@
return [].concat(targetIds).indexOf(t.id) >= 0;
});
};
c3_chart_fn.data.shown = function (targetId) {
return this.internal.filterTargetsToShow(this.data(targetId));
c3_chart_fn.data.shown = function (targetIds) {
return this.internal.filterTargetsToShow(this.data(targetIds));
};
c3_chart_fn.data.values = function (targetId) {
var target = this.data(targetId);
return target[0] ? target[0].values.map(function (d) { return d.value; }) : null;
var targets, values = null;
if (targetId) {
targets = this.data(targetId);
values = targets[0] ? targets[0].values.map(function (d) { return d.value; }) : null;
}
return values;
};
c3_chart_fn.data.names = function (names) {
return this.internal.updateDataAttributes('names', names);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -87,6 +87,11 @@ describe('c3 api data', function () {
});
});
it('should return null when no args', function () {
var values = chart.data.values();
expect(values).toBeNull();
});
});
describe('data.names()', function () {
......
......@@ -4,12 +4,16 @@ c3_chart_fn.data = function (targetIds) {
return [].concat(targetIds).indexOf(t.id) >= 0;
});
};
c3_chart_fn.data.shown = function (targetId) {
return this.internal.filterTargetsToShow(this.data(targetId));
c3_chart_fn.data.shown = function (targetIds) {
return this.internal.filterTargetsToShow(this.data(targetIds));
};
c3_chart_fn.data.values = function (targetId) {
var target = this.data(targetId);
return target[0] ? target[0].values.map(function (d) { return d.value; }) : null;
var targets, values = null;
if (targetId) {
targets = this.data(targetId);
values = targets[0] ? targets[0].values.map(function (d) { return d.value; }) : null;
}
return values;
};
c3_chart_fn.data.names = function (names) {
return this.internal.updateDataAttributes('names', names);
......
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