Browse Source

Changed axis.x.domain.min/max to zoom.x.min/max

pull/603/head
michalkop93 10 years ago
parent
commit
c92bbb43c6
  1. 1
      Gruntfile.coffee
  2. 72
      c3.js
  3. 4
      c3.min.js
  4. 33
      src/api.domain.js
  5. 32
      src/api.zoom.js
  6. 4
      src/config.js
  7. 4
      src/domain.js

1
Gruntfile.coffee

@ -65,7 +65,6 @@ module.exports = (grunt) ->
'src/api.color.js', 'src/api.color.js',
'src/api.x.js', 'src/api.x.js',
'src/api.axis.js', 'src/api.axis.js',
'src/api.domain.js',
'src/api.legend.js', 'src/api.legend.js',
'src/api.chart.js', 'src/api.chart.js',
'src/api.tooltip.js', 'src/api.tooltip.js',

72
c3.js

@ -890,6 +890,8 @@
zoom_extent: undefined, zoom_extent: undefined,
zoom_privileged: false, zoom_privileged: false,
zoom_onzoom: function () {}, zoom_onzoom: function () {},
zoom_x_min: undefined,
zoom_x_max: undefined,
interaction_enabled: true, interaction_enabled: true,
onmouseover: function () {}, onmouseover: function () {},
onmouseout: function () {}, onmouseout: function () {},
@ -974,8 +976,6 @@
axis_x_height: undefined, axis_x_height: undefined,
axis_x_extent: undefined, axis_x_extent: undefined,
axis_x_label: {}, axis_x_label: {},
axis_x_domain_min: undefined,
axis_x_domain_max: undefined,
axis_y_show: true, axis_y_show: true,
axis_y_max: undefined, axis_y_max: undefined,
axis_y_min: undefined, axis_y_min: undefined,
@ -1400,8 +1400,8 @@
}; };
c3_chart_internal_fn.trimXDomain = function (domain) { c3_chart_internal_fn.trimXDomain = function (domain) {
var $$ = this, config = $$.config, d3 = $$.d3; var $$ = this, config = $$.config, d3 = $$.d3;
var min = d3.min([$$.orgXDomain[0], config.axis_x_domain_min]); var min = d3.min([$$.orgXDomain[0], config.zoom_x_min]);
var max = d3.max([$$.orgXDomain[1], config.axis_x_domain_max]); var max = d3.max([$$.orgXDomain[1], config.zoom_x_max]);
if (domain[0] <= min) { if (domain[0] <= min) {
domain[1] = +domain[1] + (min - domain[0]); domain[1] = +domain[1] + (min - domain[0]);
domain[0] = min; domain[0] = min;
@ -5512,6 +5512,37 @@
$$.redraw({withUpdateXDomain: true}); $$.redraw({withUpdateXDomain: true});
}; };
c3_chart_fn.zoom.max = function (max) {
var $$ = this.internal, config = $$.config, d3 = $$.d3;
if (max === 0 || max) {
config.zoom_x_max = d3.max([$$.orgXDomain[1], max]);
}
else {
return config.zoom_x_max;
}
};
c3_chart_fn.zoom.min = function (min) {
var $$ = this.internal, config = $$.config, d3 = $$.d3;
if (min === 0 || min) {
config.zoom_x_min = d3.min([$$.orgXDomain[0], min]);
}
else {
return config.zoom_x_min;
}
};
c3_chart_fn.zoom.range = function (range) {
if (arguments.length) {
if (isDefined(range.max)) { this.domain.max(range.max); }
if (isDefined(range.min)) { this.domain.min(range.min); }
} else {
return {
max: this.domain.max(),
min: this.domain.min()
};
}
};
c3_chart_fn.load = function (args) { c3_chart_fn.load = function (args) {
var $$ = this.internal, config = $$.config; var $$ = this.internal, config = $$.config;
// update xs if specified // update xs if specified
@ -6126,39 +6157,6 @@
} }
}; };
c3_chart_fn.domain = function () {};
c3_chart_fn.domain.max = function (max) {
var $$ = this.internal, config = $$.config, d3 = $$.d3;
if (max === 0 || max) {
config.axis_x_domain_max = d3.max([$$.orgXDomain[1], max]);
}
else {
return config.axis_x_domain_max;
}
};
c3_chart_fn.domain.min = function (min) {
var $$ = this.internal, config = $$.config, d3 = $$.d3;
if (min === 0 || min) {
config.axis_x_domain_min = d3.min([$$.orgXDomain[0], min]);
}
else {
return config.axis_x_domain_min;
}
};
c3_chart_fn.domain.range = function (range) {
if (arguments.length) {
if (isDefined(range.max)) { this.domain.max(range.max); }
if (isDefined(range.min)) { this.domain.min(range.min); }
} else {
return {
max: this.domain.max(),
min: this.domain.min()
};
}
};
c3_chart_fn.legend = function () {}; c3_chart_fn.legend = function () {};
c3_chart_fn.legend.show = function (targetIds) { c3_chart_fn.legend.show = function (targetIds) {
var $$ = this.internal; var $$ = this.internal;

4
c3.min.js vendored

File diff suppressed because one or more lines are too long

33
src/api.domain.js

@ -1,33 +0,0 @@
c3_chart_fn.domain = function () {};
c3_chart_fn.domain.max = function (max) {
var $$ = this.internal, config = $$.config, d3 = $$.d3;
if (max === 0 || max) {
config.axis_x_domain_max = d3.max([$$.orgXDomain[1], max]);
}
else {
return config.axis_x_domain_max;
}
};
c3_chart_fn.domain.min = function (min) {
var $$ = this.internal, config = $$.config, d3 = $$.d3;
if (min === 0 || min) {
config.axis_x_domain_min = d3.min([$$.orgXDomain[0], min]);
}
else {
return config.axis_x_domain_min;
}
};
c3_chart_fn.domain.range = function (range) {
if (arguments.length) {
if (isDefined(range.max)) { this.domain.max(range.max); }
if (isDefined(range.min)) { this.domain.min(range.min); }
} else {
return {
max: this.domain.max(),
min: this.domain.min()
};
}
};

32
src/api.zoom.js

@ -10,3 +10,35 @@ c3_chart_fn.unzoom = function () {
$$.brush.clear().update(); $$.brush.clear().update();
$$.redraw({withUpdateXDomain: true}); $$.redraw({withUpdateXDomain: true});
}; };
c3_chart_fn.zoom.max = function (max) {
var $$ = this.internal, config = $$.config, d3 = $$.d3;
if (max === 0 || max) {
config.zoom_x_max = d3.max([$$.orgXDomain[1], max]);
}
else {
return config.zoom_x_max;
}
};
c3_chart_fn.zoom.min = function (min) {
var $$ = this.internal, config = $$.config, d3 = $$.d3;
if (min === 0 || min) {
config.zoom_x_min = d3.min([$$.orgXDomain[0], min]);
}
else {
return config.zoom_x_min;
}
};
c3_chart_fn.zoom.range = function (range) {
if (arguments.length) {
if (isDefined(range.max)) { this.domain.max(range.max); }
if (isDefined(range.min)) { this.domain.min(range.min); }
} else {
return {
max: this.domain.max(),
min: this.domain.min()
};
}
};

4
src/config.js

@ -11,6 +11,8 @@ c3_chart_internal_fn.getDefaultConfig = function () {
zoom_extent: undefined, zoom_extent: undefined,
zoom_privileged: false, zoom_privileged: false,
zoom_onzoom: function () {}, zoom_onzoom: function () {},
zoom_x_min: undefined,
zoom_x_max: undefined,
interaction_enabled: true, interaction_enabled: true,
onmouseover: function () {}, onmouseover: function () {},
onmouseout: function () {}, onmouseout: function () {},
@ -95,8 +97,6 @@ c3_chart_internal_fn.getDefaultConfig = function () {
axis_x_height: undefined, axis_x_height: undefined,
axis_x_extent: undefined, axis_x_extent: undefined,
axis_x_label: {}, axis_x_label: {},
axis_x_domain_min: undefined,
axis_x_domain_max: undefined,
axis_y_show: true, axis_y_show: true,
axis_y_max: undefined, axis_y_max: undefined,
axis_y_min: undefined, axis_y_min: undefined,

4
src/domain.js

@ -214,8 +214,8 @@ c3_chart_internal_fn.updateXDomain = function (targets, withUpdateXDomain, withU
}; };
c3_chart_internal_fn.trimXDomain = function (domain) { c3_chart_internal_fn.trimXDomain = function (domain) {
var $$ = this, config = $$.config, d3 = $$.d3; var $$ = this, config = $$.config, d3 = $$.d3;
var min = d3.min([$$.orgXDomain[0], config.axis_x_domain_min]); var min = d3.min([$$.orgXDomain[0], config.zoom_x_min]);
var max = d3.max([$$.orgXDomain[1], config.axis_x_domain_max]); var max = d3.max([$$.orgXDomain[1], config.zoom_x_max]);
if (domain[0] <= min) { if (domain[0] <= min) {
domain[1] = +domain[1] + (min - domain[0]); domain[1] = +domain[1] + (min - domain[0]);
domain[0] = min; domain[0] = min;

Loading…
Cancel
Save