Browse Source

Added ondragstart and ondragend events

fixes #1366
pull/1367/head
Germain Bergeron 9 years ago
parent
commit
5a2d116cf8
  1. 1
      htdocs/samples/selection.html
  2. 2
      src/config.js
  3. 2
      src/drag.js

1
htdocs/samples/selection.html

@ -42,6 +42,7 @@
enabled: true,
grouped: true,
multiple: true,
draggable: true
},
onclick: function (d, element) { console.log("onclick", d, element); },
onselected: function (d, element) { console.log("onselected", d, element); },

2
src/config.js

@ -54,6 +54,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,

2
src/drag.js

@ -60,6 +60,7 @@ c3_chart_internal_fn.dragstart = function (mouse) {
var $$ = this, config = $$.config;
if ($$.hasArcType()) { return; }
if (! config.data_selection_enabled) { return; } // do nothing if not selectable
$$.config.data_ondragstart.call($$);
$$.dragStart = mouse;
$$.main.select('.' + CLASS.chart).append('rect')
.attr('class', CLASS.dragarea)
@ -71,6 +72,7 @@ c3_chart_internal_fn.dragend = function () {
var $$ = this, config = $$.config;
if ($$.hasArcType()) { return; }
if (! config.data_selection_enabled) { return; } // do nothing if not selectable
$$.config.data_ondragend.call($$);
$$.main.select('.' + CLASS.dragarea)
.transition().duration(100)
.style('opacity', 0)

Loading…
Cancel
Save