// Code for a variety of interaction models. Used in interaction.html, but split out from
// that file so they can be tested in isolation.
//
// Code for a variety of interaction models. Used in interaction.html, but split out from
// that file so they can be tested in isolation.
//
var h = g.toDomCoords(null, yar0[0])[1] - yOffset;
// Percentage from the left.
var h = g.toDomCoords(null, yar0[0])[1] - yOffset;
// Percentage from the left.
// The (1-) part below changes it from "% distance down from the top"
// to "% distance up from the bottom".
// The (1-) part below changes it from "% distance down from the top"
// to "% distance up from the bottom".
function dblClickV3(event, g, context) {
// Reducing by 20% makes it 80% the original size, which means
// to restore to original size it must grow by 25%
function dblClickV3(event, g, context) {
// Reducing by 20% makes it 80% the original size, which means
// to restore to original size it must grow by 25%
var percentages = offsetToPercentage(g, event.offsetX, event.offsetY);
var xPct = percentages[0];
var yPct = percentages[1];
if (event.ctrlKey) {
var percentages = offsetToPercentage(g, event.offsetX, event.offsetY);
var xPct = percentages[0];
var yPct = percentages[1];
if (event.ctrlKey) {
- zoom(g, -.25, xPct, yPct);
+ zoom(g, -0.25, xPct, yPct);
- zoom(g, +.2, xPct, yPct);
+ zoom(g, +0.2, xPct, yPct);
// that verbatim, it would be a 7.5%.
var percentage = normal / 50;
// that verbatim, it would be a 7.5%.
var percentage = normal / 50;
var percentages = offsetToPercentage(g, event.offsetX, event.offsetY);
var xPct = percentages[0];
var yPct = percentages[1];
var percentages = offsetToPercentage(g, event.offsetX, event.offsetY);
var xPct = percentages[0];
var yPct = percentages[1];
- var canvasx = Dygraph.pageX(event) - Dygraph.findPosX(g.graphDiv);
- var canvasy = Dygraph.pageY(event) - Dygraph.findPosY(g.graphDiv);
+ var graphPos = Dygraph.findPos(g.graphDiv);
+ var canvasx = Dygraph.pageX(event) - graphPos.x;
+ var canvasy = Dygraph.pageY(event) - graphPos.y;
for (var col = 1; col < 3; col++) {
// TODO(konigsberg): these will throw exceptions as data is removed.
var vals = g.getValue(row, col);
for (var col = 1; col < 3; col++) {
// TODO(konigsberg): these will throw exceptions as data is removed.
var vals = g.getValue(row, col);
var val = vals[0];
var y = g.toDomCoords(null, val)[1];
var diff2 = Math.abs(canvasy - y);
var val = vals[0];
var y = g.toDomCoords(null, val)[1];
var diff2 = Math.abs(canvasy - y);