From 669ad174dff994a3289dda71a90176869f1a0f3e Mon Sep 17 00:00:00 2001 From: pkalakota Date: Fri, 3 Feb 2017 01:51:01 +0530 Subject: [PATCH] double click handler implementation --- src/config.js | 3 ++- src/interaction.js | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/config.js b/src/config.js index c127be5..d4194b5 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 c6203d9..ea694f5 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)