Browse Source

add ondragend callback issue 1442

pull/1443/head
Irina Abramova 9 years ago
parent
commit
4980185f40
  1. 2
      src/config.js
  2. 1
      src/core.js
  3. 11
      src/drag.js

2
src/config.js

@ -55,6 +55,8 @@ c3_chart_internal_fn.getDefaultConfig = function () {
data_onmouseout: function () {},
data_onselected: function () {},
data_onunselected: function () {},
data_ondragstart : function () {},
data_ondragend : function () {},
data_url: undefined,
data_json: undefined,
data_rows: undefined,

1
src/core.js

@ -113,6 +113,7 @@ c3_chart_internal_fn.initParams = function () {
$$.clipPathForSubchart = $$.getClipPath($$.clipIdForSubchart),
$$.dragStart = null;
$$.dragCurrent = null;
$$.dragging = false;
$$.flowing = false;
$$.cancelClick = false;

11
src/drag.js

@ -9,6 +9,7 @@ c3_chart_internal_fn.drag = function (mouse) {
sx = $$.dragStart[0];
sy = $$.dragStart[1];
$$.dragCurrent = mouse;
mx = mouse[0];
my = mouse[1];
minX = Math.min(sx, mx);
@ -68,7 +69,11 @@ c3_chart_internal_fn.dragstart = function (mouse) {
};
c3_chart_internal_fn.dragend = function () {
var $$ = this, config = $$.config;
var $$ = this, config = $$.config,
sx = $$.dragStart[0],
mx = $$.dragCurrent ? $$.dragCurrent[0] : sx,
minX = Math.min(sx, mx),
maxX = Math.max(sx, mx);
if ($$.hasArcType()) { return; }
if (! config.data_selection_enabled) { return; } // do nothing if not selectable
$$.main.select('.' + CLASS.dragarea)
@ -77,5 +82,9 @@ c3_chart_internal_fn.dragend = function () {
.remove();
$$.main.selectAll('.' + CLASS.shape)
.classed(CLASS.INCLUDED, false);
if (config.data_ondragend) {
var drag_extent = [this.x.invert(minX), this.x.invert(maxX)];
config.data_ondragend(drag_extent);
}
$$.dragging = false;
};

Loading…
Cancel
Save