Browse Source

Merge branch 'dungsaga-master'

pull/742/head
Masayuki Tanaka 10 years ago
parent
commit
e7f976df69
  1. 2
      c3.js
  2. 4
      c3.min.js
  3. 25
      spec/api.data-spec.js
  4. 2
      src/api.data.js

2
c3.js

@ -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);

4
c3.min.js vendored

File diff suppressed because one or more lines are too long

25
spec/api.data-spec.js

@ -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 () {

2
src/api.data.js

@ -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);

Loading…
Cancel
Save