diff --git a/src/config.js b/src/config.js index c127be516..d4194b502 100644 --- a/src/config.js +++ b/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 () {}, @@ -121,7 +122,7 @@ c3_chart_internal_fn.getDefaultConfig = function () { axis_y_label: {}, axis_y_tick_format: undefined, axis_y_tick_outer: true, - axis_y_tick_values: null, + axis_y_tick_values: null, axis_y_tick_rotate: 0, axis_y_tick_count: undefined, axis_y_tick_time_value: undefined, diff --git a/src/interaction.js b/src/interaction.js index c6203d93e..ea694f58f 100644 --- a/src/interaction.js +++ b/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)