Browse Source

double click handler implementation

pull/1952/head
pkalakota 8 years ago
parent
commit
669ad174df
  1. 1
      src/config.js
  2. 25
      src/interaction.js

1
src/config.js

@ -52,6 +52,7 @@ c3_chart_internal_fn.getDefaultConfig = function () {
data_selection_multiple: true,
data_selection_draggable: false,
data_onclick: function () {},
data_ondblclick: function () {},
data_onmouseover: function () {},
data_onmouseout: function () {},
data_onselected: function () {},

25
src/interaction.js

@ -214,6 +214,31 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) {
}
});
})
.call(
config.data_selection_draggable && $$.drag ? (
d3.behavior.drag().origin(Object)
.on('drag', function () { $$.drag(d3.mouse(this)); })
.on('dragstart', function () { $$.dragstart(d3.mouse(this)); })
.on('dragend', function () { $$.dragend(); })
) : function () {}
)
.on('dblclick', function (d) {
var index = d.index;
if ($$.hasArcType() || !$$.toggleShape) { return; }
if ($$.cancelClick) {
$$.cancelClick = false;
return;
}
if ($$.isStepType(d) && config.line_step_type === 'step-after' && d3.mouse(this)[0] < $$.x($$.getXValue(d.id, index))) {
index -= 1;
}
$$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) {
if (config.data_selection_grouped || $$.isWithinShape(this, d)) {
$$.toggleShape(this, d, index);
$$.config.data_ondblclick.call($$.api, d, this);
}
});
})
.call(
config.data_selection_draggable && $$.drag ? (
d3.behavior.drag().origin(Object)

Loading…
Cancel
Save