Browse Source

Fix empty data when timeseries - #737

pull/742/head
Masayuki Tanaka 10 years ago
parent
commit
9416914ec1
  1. 2
      c3.js
  2. 2
      c3.min.js
  3. 45
      spec/core-spec.js
  4. 2
      src/data.js

2
c3.js

@ -1576,10 +1576,12 @@
};
c3_chart_internal_fn.updateXs = function () {
var $$ = this;
if ($$.data.targets.length) {
$$.xs = [];
$$.data.targets[0].values.forEach(function (v) {
$$.xs[v.index] = v.x;
});
}
};
c3_chart_internal_fn.getPrevX = function (i) {
var x = this.xs[i - 1];

2
c3.min.js vendored

File diff suppressed because one or more lines are too long

45
spec/core-spec.js

@ -70,4 +70,49 @@ describe('c3 chart', function () {
});
describe('empty data', function () {
it('should upaate args for empty data', function () {
args = {
data: {
columns: [
['data1'],
['data2']
]
}
};
expect(true).toBeTruthy();
});
it('should generate a chart', function () {
var ticks = chart.internal.main.select('.c3-axis-x').selectAll('g.tick');
expect(ticks.size()).toBe(0);
});
it('should upaate args for empty data', function () {
args = {
data: {
x: 'x',
columns: [
['x'],
['data1'],
['data2']
]
},
axis: {
x: {
type: 'timeseries'
}
}
};
expect(true).toBeTruthy();
});
it('should generate a chart', function () {
var ticks = chart.internal.main.select('.c3-axis-x').selectAll('g.tick');
expect(ticks.size()).toBe(0);
});
});
});

2
src/data.js

@ -102,10 +102,12 @@ c3_chart_internal_fn.cloneTarget = function (target) {
};
c3_chart_internal_fn.updateXs = function () {
var $$ = this;
if ($$.data.targets.length) {
$$.xs = [];
$$.data.targets[0].values.forEach(function (v) {
$$.xs[v.index] = v.x;
});
}
};
c3_chart_internal_fn.getPrevX = function (i) {
var x = this.xs[i - 1];

Loading…
Cancel
Save