Commit eef2dba0 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Add data.axes API

parents b17c3ab2 b93b77d0
......@@ -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;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -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');
});
});
});
......@@ -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;
};
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