{"action":"created","issue":{"url":"https://api.github.com/repos/danvk/dygraphs/issues/374","labels_url":"https://api.github.com/repos/danvk/dygraphs/issues/374/labels{/name}","comments_url":"https://api.github.com/repos/danvk/dygraphs/issues/374/comments","events_url":"https://api.github.com/repos/danvk/dygraphs/issues/374/events","html_url":"https://github.com/danvk/dygraphs/issues/374","id":46334619,"number":374,"title":"Generic option to disable panning along axis of choice","user":{"login":"danvk","id":98301,"avatar_url":"https://avatars.githubusercontent.com/u/98301?v=3","gravatar_id":"","url":"https://api.github.com/users/danvk","html_url":"https://github.com/danvk","followers_url":"https://api.github.com/users/danvk/followers","following_url":"https://api.github.com/users/danvk/following{/other_user}","gists_url":"https://api.github.com/users/danvk/gists{/gist_id}","starred_url":"https://api.github.com/users/danvk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danvk/subscriptions","organizations_url":"https://api.github.com/users/danvk/orgs","repos_url":"https://api.github.com/users/danvk/repos","events_url":"https://api.github.com/users/danvk/events{/privacy}","received_events_url":"https://api.github.com/users/danvk/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/danvk/dygraphs/labels/2%E2%80%935%20stars","name":"2–5 stars","color":"fad8c7"},{"url":"https://api.github.com/repos/danvk/dygraphs/labels/Component-Interaction","name":"Component-Interaction","color":"FFFFFF"},{"url":"https://api.github.com/repos/danvk/dygraphs/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/danvk/dygraphs/labels/imported","name":"imported","color":"FFFFFF"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2014-10-20T22:42:59Z","updated_at":"2015-09-11T09:17:47Z","closed_at":null,"body":"_From [sasha.mi...@gmail.com](https://code.google.com/u/111565109038566742607/) on September 20, 2012 17:37:24_\n\nI found myself going through dygraph code in order to disable panning along y axis. It would be nice to have this as an option, like:\r\n\r\ndisableValueRangePan: true|false (default: false)\r\ndisableDateWindowPan: true|false (default: false)\r\n\r\nThis would be especially useful for mobile and tablet devices, where you can get easily lost in the graph and when panning along both axis is not required.\n\n_Original issue: http://code.google.com/p/dygraphs/issues/detail?id=384_"},"comment":{"url":"https://api.github.com/repos/danvk/dygraphs/issues/comments/139496441","html_url":"https://github.com/danvk/dygraphs/issues/374#issuecomment-139496441","issue_url":"https://api.github.com/repos/danvk/dygraphs/issues/374","id":139496441,"user":{"login":"davidebianchi","id":10374360,"avatar_url":"https://avatars.githubusercontent.com/u/10374360?v=3","gravatar_id":"","url":"https://api.github.com/users/davidebianchi","html_url":"https://github.com/davidebianchi","followers_url":"https://api.github.com/users/davidebianchi/followers","following_url":"https://api.github.com/users/davidebianchi/following{/other_user}","gists_url":"https://api.github.com/users/davidebianchi/gists{/gist_id}","starred_url":"https://api.github.com/users/davidebianchi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidebianchi/subscriptions","organizations_url":"https://api.github.com/users/davidebianchi/orgs","repos_url":"https://api.github.com/users/davidebianchi/repos","events_url":"https://api.github.com/users/davidebianchi/events{/privacy}","received_events_url":"https://api.github.com/users/davidebianchi/received_events","type":"User","site_admin":false},"created_at":"2015-09-11T09:17:47Z","updated_at":"2015-09-11T09:17:47Z","body":"Hi @PureSpider, this code is a modification of the `moveTouch` function, originally written by @danvk. \r\n\r\nIt should be quite simple to add to the library an option to enable zoom only on the y or x axis.\r\n\r\n    Dygraph.Interaction.moveTouch = function (event, g, context) {\r\n                // If the tap moves, then it's definitely not part of a double-tap.\r\n        context.startTimeForDoubleTapMs = null;\r\n\r\n        var i = [];\r\n        var touches = [];\r\n        for (i = 0; i < event.touches.length; i++) {\r\n            var t = event.touches[i];\r\n            touches.push({\r\n                pageX: t.pageX\r\n            });\r\n        }\r\n        var initialTouches = context.initialTouches;\r\n\r\n        var c_now;\r\n\r\n        // old and new centers.\r\n        var c_init = context.initialPinchCenter;\r\n        if (touches.length === 1) {\r\n            c_now = touches[0];\r\n        } else {\r\n            c_now = {\r\n                pageX: 0.5 * (touches[0].pageX + touches[1].pageX)\r\n            };\r\n        }\r\n\r\n          // this is the \"swipe\" component\r\n          // we toss it out for now, but could use it in the future.\r\n        var swipe = {\r\n            pageX: c_now.pageX - c_init.pageX\r\n        };\r\n        var dataWidth = context.initialRange.x[1] - context.initialRange.x[0];\r\n        var dataHeight = context.initialRange.y[0] - context.initialRange.y[1];\r\n        swipe.dataX = (swipe.pageX / g.plotter_.area.w) * dataWidth;\r\n        var xScale;\r\n\r\n        // The residual bits are usually split into scale & rotate bits, but we split\r\n        // them into x-scale and y-scale bits.\r\n        if (touches.length === 1) {\r\n            xScale = 1.0;\r\n        } else if (touches.length >= 2) {\r\n            var initHalfWidth = (initialTouches[1].pageX - c_init.pageX);\r\n            xScale = (touches[1].pageX - c_now.pageX) / initHalfWidth;\r\n        }\r\n\r\n        // Clip scaling to [1/8, 8] to prevent too much blowup.\r\n        xScale = Math.min(8, Math.max(0.125, xScale));\r\n\r\n        var didZoom = false;\r\n        if (context.touchDirections.x) {\r\n            g.dateWindow_ = [\r\n                c_init.dataX - swipe.dataX + (context.initialRange.x[0] - c_init.dataX) / xScale,\r\n                c_init.dataX - swipe.dataX + (context.initialRange.x[1] - c_init.dataX) / xScale\r\n            ];\r\n            didZoom = true;\r\n        }\r\n\r\n        g.drawGraph_(false);\r\n\r\n        // We only call zoomCallback on zooms, not pans, to mirror desktop behavior.\r\n        if (didZoom && touches.length > 1 && g.getFunctionOption(\"zoomCallback\")) {\r\n            var viewWindow = g.xAxisRange();\r\n            g.getFunctionOption(\"zoomCallback\").call(g, viewWindow[0], viewWindow[1], g.yAxisRanges());\r\n        }\r\n    }; "}}