-DygraphOps.dispatchMouseUp = function(g, x, y, func) {
- var px = Dygraph.findPosX(g.canvas_);
- var py = Dygraph.findPosY(g.canvas_);
-
- var pageX = px + g.toDomXCoord(x);
- var pageY = py + g.toDomYCoord(y);
-
- var evt = document.createEvent('MouseEvents');
- evt.initMouseEvent(
- 'mouseup',
- true, true, document.defaultView,
- 0, pageX, pageY, pageX, pageY,
- false, false, false, false, 0, null);
- if (func) {
- func(evt);
- }
- g.canvas_.dispatchEvent(evt);
+DygraphOps.dispatchDoubleClick = function(g, custom) {
+ var opts = {
+ type : 'dblclick',
+ detail : 2
+ };
+ var event = DygraphOps.createEvent(opts, custom);
+ DygraphOps.dispatchCanvasEvent(g, event);
+};
+
+/*
+ * Create an 'opts' argument which can be passed to createEvent that contains
+ * type, screenX, screenY, clientX, clientY.
+ */
+DygraphOps.createOptsForPoint_ = function(g, type, x, y) {
+ var pos = utils.findPos(g.canvas_);
+ var pageX = pos.x + x;
+ var pageY = pos.y + y;
+
+ return {
+ type : type,
+ screenX : pageX,
+ screenY : pageY,
+ clientX : pageX,
+ clientY : pageY,
+ };
+};
+
+DygraphOps.dispatchMouseDown_Point = function(g, x, y, custom) {
+ var opts = DygraphOps.createOptsForPoint_(g, 'mousedown', x, y);
+ opts.detail = 1;
+ var event = DygraphOps.createEvent(opts, custom);
+ DygraphOps.dispatchCanvasEvent(g, event);
+};
+
+DygraphOps.dispatchMouseMove_Point = function(g, x, y, custom) {
+ var opts = DygraphOps.createOptsForPoint_(g, 'mousemove', x, y);
+ var event = DygraphOps.createEvent(opts, custom);
+ DygraphOps.dispatchCanvasEvent(g, event);
+};
+
+DygraphOps.dispatchMouseUp_Point = function(g, x, y, custom) {
+ var opts = DygraphOps.createOptsForPoint_(g, 'mouseup', x, y);
+ var event = DygraphOps.createEvent(opts, custom);
+ DygraphOps.dispatchCanvasEvent(g, event);
+};
+
+DygraphOps.dispatchMouseOver_Point = function(g, x, y, custom) {
+ var opts = DygraphOps.createOptsForPoint_(g, 'mouseover', x, y);
+ var event = DygraphOps.createEvent(opts, custom);
+ DygraphOps.dispatchCanvasEvent(g, event);
+};
+
+DygraphOps.dispatchMouseOut_Point = function(g, x, y, custom) {
+ var opts = DygraphOps.createOptsForPoint_(g, 'mouseout', x, y);
+ var event = DygraphOps.createEvent(opts, custom);
+ DygraphOps.dispatchCanvasEvent(g, event);
+};
+
+/**
+ * Dispatches a mouse down using the graph's data coordinate system.
+ * (The y value mapped to the first axis.)
+ */
+DygraphOps.dispatchMouseDown = function(g, x, y, custom) {
+ DygraphOps.dispatchMouseDown_Point(
+ g,
+ g.toDomXCoord(x),
+ g.toDomYCoord(y),
+ custom);
+};
+
+/**
+ * Dispatches a mouse move using the graph's data coordinate system.
+ * (The y value mapped to the first axis.)
+ */
+DygraphOps.dispatchMouseMove = function(g, x, y, custom) {
+ DygraphOps.dispatchMouseMove_Point(
+ g,
+ g.toDomXCoord(x),
+ g.toDomYCoord(y),
+ custom);
+};
+
+/**
+ * Dispatches a mouse up using the graph's data coordinate system.
+ * (The y value mapped to the first axis.)
+ */
+DygraphOps.dispatchMouseUp = function(g, x, y, custom) {
+ DygraphOps.dispatchMouseUp_Point(
+ g,
+ g.toDomXCoord(x),
+ g.toDomYCoord(y),
+ custom);
+};
+
+/**
+ * Dispatches a mouse over using the graph's data coordinate system.
+ * (The y value mapped to the first axis.)
+ */
+DygraphOps.dispatchMouseOver = function(g, x, y, custom) {
+ DygraphOps.dispatchMouseOver_Point(
+ g,
+ g.toDomXCoord(x),
+ g.toDomYCoord(y),
+ custom);