Browse Source

Merge branch 'lbortoli-master'

pull/676/head
Masayuki Tanaka 10 years ago
parent
commit
937f3835da
  1. 9
      c3.js
  2. 4
      c3.min.js
  3. 36
      spec/api.data-spec.js
  4. 9
      src/api.data.js

9
c3.js

@ -6136,6 +6136,15 @@
$$.redraw({withLegend: true});
return config.data_colors;
};
c3_chart_fn.data.axes = function (axes) {
var $$ = this.internal, config = $$.config;
if (!arguments.length) { return config.data_axes; }
Object.keys(axes).forEach(function (id) {
config.data_axes[id] = axes[id];
});
$$.redraw({withLegend: true});
return config.data_axes;
};
c3_chart_fn.category = function (i, category) {
var $$ = this.internal, config = $$.config;

4
c3.min.js vendored

File diff suppressed because one or more lines are too long

36
spec/api.data-spec.js

@ -12,8 +12,17 @@ describe('c3 api data', function () {
data: {
columns: [
['data1', 30, 200, 100, 400, 150, 250],
['data2', 50, 20, 10, 40, 15, 25]
]
['data2', 5000, 2000, 1000, 4000, 1500, 2500]
],
axes: {
data1: 'y',
data2: 'y2'
}
},
axis: {
y2: {
show: true
}
}
};
@ -69,4 +78,27 @@ describe('c3 api data', function () {
});
describe('data.axes()', function () {
it('should return data.axes specified as argument', function () {
var results = chart.data.axes();
expect(results.data1).toBe('y');
expect(results.data2).toBe('y2');
expect(d3.select('.c3-axis-y g.tick text').text()).toBe('0');
expect(d3.select('.c3-axis-y2 g.tick text').text()).toBe('1000');
});
it('should return data.axes specified as api', function () {
var results = chart.data.axes({
data1: 'y2',
data2: 'y'
});
expect(results.data1).toBe('y2');
expect(results.data2).toBe('y');
expect(d3.select('.c3-axis-y g.tick text').text()).toBe('1000');
expect(d3.select('.c3-axis-y2 g.tick text').text()).toBe('0');
});
});
});

9
src/api.data.js

@ -29,3 +29,12 @@ c3_chart_fn.data.colors = function (colors) {
$$.redraw({withLegend: true});
return config.data_colors;
};
c3_chart_fn.data.axes = function (axes) {
var $$ = this.internal, config = $$.config;
if (!arguments.length) { return config.data_axes; }
Object.keys(axes).forEach(function (id) {
config.data_axes[id] = axes[id];
});
$$.redraw({withLegend: true});
return config.data_axes;
};

Loading…
Cancel
Save