From: Dan Vanderkam Date: Sun, 1 Sep 2013 19:55:52 +0000 (-0400) Subject: interaction is working X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=f5d726af0bff0ee89f842fd590b747d4b95d5f49;p=dygraphs.git interaction is working --- diff --git a/dygraph-externs.js b/dygraph-externs.js index 4ec5846..3cc89b7 100644 --- a/dygraph-externs.js +++ b/dygraph-externs.js @@ -173,3 +173,8 @@ DygraphPluginType.prototype.activate = function(dygraph) {}; DygraphPluginType.prototype.toString = function() {}; DygraphPluginType.prototype.destroy = function() {}; + +// Convenience for debugging -- makes "console.log" compile-able. +var console = {}; +/** @param {...} varargs */ +console.log = function(varargs) {}; diff --git a/dygraph-interaction-model.js b/dygraph-interaction-model.js index 00feccc..5bb491f 100644 --- a/dygraph-interaction-model.js +++ b/dygraph-interaction-model.js @@ -278,8 +278,8 @@ Dygraph.Interaction.moveZoom = function(event, g, context) { * @param {!DygraphInteractionContext} context */ Dygraph.Interaction.treatMouseOpAsClick = function(g, event, context) { - var clickCallback = /**@type{Function}*/(g.attr_('clickCallback')); - var pointClickCallback = /**@type{Function}*/(g.attr_('pointClickCallback')); + var clickCallback = g.getFunctionOption('clickCallback'); + var pointClickCallback = g.getFunctionOption('pointClickCallback'); var selectedPoint = null; @@ -302,7 +302,7 @@ Dygraph.Interaction.treatMouseOpAsClick = function(g, event, context) { } // Allow any click within two pixels of the dot. - var radius = g.attr_('highlightCircleSize') + 2; + var radius = g.getNumericOption('highlightCircleSize') + 2; if (closestDistance <= radius * radius) { selectedPoint = g.selPoints_[closestIdx]; } @@ -568,7 +568,7 @@ Dygraph.Interaction.endTouch = function(event, g, context) { */ Dygraph.Interaction.defaultModel = { // Track the beginning of drag events - mousedown: function(event, g, context) { + 'mousedown': function(event, g, context) { // Right-click should not initiate a zoom. if (event.button && event.button == 2) return; @@ -582,7 +582,7 @@ Dygraph.Interaction.defaultModel = { }, // Draw zoom rectangles when the mouse is down and the user moves around - mousemove: function(event, g, context) { + 'mousemove': function(event, g, context) { if (context.isZooming) { Dygraph.moveZoom(event, g, context); } else if (context.isPanning) { @@ -590,7 +590,7 @@ Dygraph.Interaction.defaultModel = { } }, - mouseup: function(event, g, context) { + 'mouseup': function(event, g, context) { if (context.isZooming) { Dygraph.endZoom(event, g, context); } else if (context.isPanning) { @@ -598,18 +598,18 @@ Dygraph.Interaction.defaultModel = { } }, - touchstart: function(event, g, context) { + 'touchstart': function(event, g, context) { Dygraph.Interaction.startTouch(event, g, context); }, - touchmove: function(event, g, context) { + 'touchmove': function(event, g, context) { Dygraph.Interaction.moveTouch(event, g, context); }, - touchend: function(event, g, context) { + 'touchend': function(event, g, context) { Dygraph.Interaction.endTouch(event, g, context); }, // Temporarily cancel the dragging event when the mouse leaves the graph - mouseout: function(event, g, context) { + 'mouseout': function(event, g, context) { if (context.isZooming) { context.dragEndX = null; context.dragEndY = null; @@ -618,7 +618,7 @@ Dygraph.Interaction.defaultModel = { }, // Disable zooming out if panning. - dblclick: function(event, g, context) { + 'dblclick': function(event, g, context) { if (context.cancelNextDblclick) { context.cancelNextDblclick = false; return; @@ -630,7 +630,7 @@ Dygraph.Interaction.defaultModel = { } }; -Dygraph.DEFAULT_ATTRS.interactionModel = Dygraph.Interaction.defaultModel; +Dygraph.DEFAULT_ATTRS['interactionModel'] = Dygraph.Interaction.defaultModel; // old ways of accessing these methods/properties Dygraph.defaultInteractionModel = Dygraph.Interaction.defaultModel; @@ -642,10 +642,10 @@ Dygraph.movePan = Dygraph.Interaction.movePan; Dygraph.startPan = Dygraph.Interaction.startPan; Dygraph.Interaction.nonInteractiveModel_ = { - mousedown: function(event, g, context) { + 'mousedown': function(event, g, context) { context.initializeMouseDown(event, g, context); }, - mouseup: function(event, g, context) { + 'mouseup': function(event, g, context) { // TODO(danvk): this logic is repeated in Dygraph.Interaction.endZoom context.dragEndX = Dygraph.dragGetX_(event, context); context.dragEndY = Dygraph.dragGetY_(event, context); @@ -661,16 +661,16 @@ Dygraph.Interaction.nonInteractiveModel_ = { // Default interaction model when using the range selector. Dygraph.Interaction.dragIsPanInteractionModel = { - mousedown: function(event, g, context) { + 'mousedown': function(event, g, context) { context.initializeMouseDown(event, g, context); Dygraph.startPan(event, g, context); }, - mousemove: function(event, g, context) { + 'mousemove': function(event, g, context) { if (context.isPanning) { Dygraph.movePan(event, g, context); } }, - mouseup: function(event, g, context) { + 'mouseup': function(event, g, context) { if (context.isPanning) { Dygraph.endPan(event, g, context); } diff --git a/dygraph.js b/dygraph.js index c413166..d9695a2 100644 --- a/dygraph.js +++ b/dygraph.js @@ -281,7 +281,6 @@ Dygraph.prototype.init_ = function(div, file, opt_attrs) { } } } - window.console.log(this.eventListeners_); this.createDragInterface_(); diff --git a/plugins/legend.js b/plugins/legend.js index 2877987..3a5a232 100644 --- a/plugins/legend.js +++ b/plugins/legend.js @@ -138,7 +138,6 @@ legend.prototype.deselect = function(e) { }; legend.prototype.didDrawChart = function(e) { - window.console.log('legend.didDrawChart'); this.deselect(e); }; @@ -152,7 +151,6 @@ legend.prototype.didDrawChart = function(e) { * @private */ legend.prototype.predraw = function(e) { - window.console.log('legend.predraw'); // Don't touch a user-specified labelsDiv. if (!this.is_generated_div_) return;