Merge pull request #280 from danvk/kill-code
[dygraphs.git] / gallery / drawing.js
index eef3091..b25341b 100644 (file)
@@ -10,7 +10,7 @@ Gallery.register(
           "<div id='tool_pencil'></div>",
           "<div id='tool_eraser'></div>",
           "</div>",
-          "<div id='draw_div' style='width: 800px; height: 400px;'></div>",
+          "<div id='draw_div' style='width: 600px; height: 300px;'></div>",
           "<p style='font-size: 10pt'>Toolbar/cursor icons are CC-licensed from ",
           "<a href='http://www.fatcow.com/free-icons'>FatCow</a>.</p>"].join("\n");
     },
@@ -37,8 +37,9 @@ Gallery.register(
       var valueRange = [0, 100];
   
       function setPoint(event, g, context) {
-        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;
         var xy = g.toDataCoords(canvasx, canvasy);
         var x = xy[0], value = xy[1];
         var rows = g.numRows();
@@ -179,4 +180,4 @@ Gallery.register(
           });
           window.onmouseup = finishDraw;
       }
-  });
\ No newline at end of file
+  });