Commit e7f976df authored by Masayuki Tanaka's avatar Masayuki Tanaka

Merge branch 'dungsaga-master'

parents 34508a2d 1eedee35
......@@ -6246,7 +6246,7 @@
};
c3_chart_fn.data.values = function (targetId) {
var target = this.data(targetId);
return target ? target.values.map(function (d) { return d.value; }) : null;
return target[0] ? target[0].values.map(function (d) { return d.value; }) : null;
};
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.
......@@ -35,18 +35,8 @@ describe('c3 api data', function () {
};
beforeEach(function (done) {
if (typeof chart === 'undefined') {
window.initDom();
}
chart = window.c3.generate(args);
chart = window.initChart(chart, args, done);
d3 = chart.internal.d3;
chart.internal.d3.select('.jasmine_html-reporter')
.style('position', 'absolute')
.style('right', 0);
window.setTimeout(function () {
done();
}, 10);
});
describe('data()', function () {
......@@ -86,6 +76,19 @@ describe('c3 api data', function () {
});
describe('data.values()', function () {
it('should return values for specified target', function () {
var values = chart.data.values('data1'),
expectedValues = [30, 200, 100, 400, 150, 250];
expect(values.length).toBe(6);
values.forEach(function (v, i) {
expect(v).toBe(expectedValues[i]);
});
});
});
describe('data.names()', function () {
it('should return data.names specified as argument', function () {
......
......@@ -9,7 +9,7 @@ c3_chart_fn.data.shown = function (targetId) {
};
c3_chart_fn.data.values = function (targetId) {
var target = this.data(targetId);
return target ? target.values.map(function (d) { return d.value; }) : null;
return target[0] ? target[0].values.map(function (d) { return d.value; }) : null;
};
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