Browse Source

Merge branch 'michalkop93-dataOrder'

pull/631/head
Masayuki Tanaka 10 years ago
parent
commit
313ed15dd1
  1. 4
      c3.js
  2. 6
      c3.min.js
  3. 33
      spec/data-spec.js
  4. 4
      src/data.js

4
c3.js

@ -1630,11 +1630,11 @@
}; };
c3_chart_internal_fn.isOrderDesc = function () { c3_chart_internal_fn.isOrderDesc = function () {
var config = this.config; var config = this.config;
return config.data_order && config.data_order.toLowerCase() === 'desc'; return typeof(config.data_order) === 'string' && config.data_order.toLowerCase() === 'desc';
}; };
c3_chart_internal_fn.isOrderAsc = function () { c3_chart_internal_fn.isOrderAsc = function () {
var config = this.config; var config = this.config;
return config.data_order && config.data_order.toLowerCase() === 'asc'; return typeof(config.data_order) === 'string' && config.data_order.toLowerCase() === 'asc';
}; };
c3_chart_internal_fn.orderTargets = function (targets) { c3_chart_internal_fn.orderTargets = function (targets) {
var $$ = this, config = $$.config, orderAsc = $$.isOrderAsc(), orderDesc = $$.isOrderDesc(); var $$ = this, config = $$.config, orderAsc = $$.isOrderAsc(), orderDesc = $$.isOrderDesc();

6
c3.min.js vendored

File diff suppressed because one or more lines are too long

33
spec/data-spec.js

@ -0,0 +1,33 @@
var describe = window.describe,
expect = window.expect,
it = window.it,
beforeEach = window.beforeEach;
describe('c3 chart data', function () {
'use strict';
var chart, d3;
beforeEach(function () {
window.initDom();
chart = window.c3.generate({
data: {
columns: [
['data1', 30, 200, 100, 400, 150, 250],
['data2', 50, 20, 10, 40, 15, 25],
['data3', 150, 120, 110, 140, 115, 125]
],
order: function () {
return 0;
}
}
});
d3 = chart.internal.d3;
});
describe('function in data.order', function () {
it('should return false in isOrderAsc and isOrderDesc functions', function () {
expect(chart.internal.isOrderAsc() || chart.internal.isOrderDesc()).toBe(false);
});
});
});

4
src/data.js

@ -206,11 +206,11 @@ c3_chart_internal_fn.hasPositiveValueInTargets = function (targets) {
}; };
c3_chart_internal_fn.isOrderDesc = function () { c3_chart_internal_fn.isOrderDesc = function () {
var config = this.config; var config = this.config;
return config.data_order && config.data_order.toLowerCase() === 'desc'; return typeof(config.data_order) === 'string' && config.data_order.toLowerCase() === 'desc';
}; };
c3_chart_internal_fn.isOrderAsc = function () { c3_chart_internal_fn.isOrderAsc = function () {
var config = this.config; var config = this.config;
return config.data_order && config.data_order.toLowerCase() === 'asc'; return typeof(config.data_order) === 'string' && config.data_order.toLowerCase() === 'asc';
}; };
c3_chart_internal_fn.orderTargets = function (targets) { c3_chart_internal_fn.orderTargets = function (targets) {
var $$ = this, config = $$.config, orderAsc = $$.isOrderAsc(), orderDesc = $$.isOrderDesc(); var $$ = this, config = $$.config, orderAsc = $$.isOrderAsc(), orderDesc = $$.isOrderDesc();

Loading…
Cancel
Save