* @param { Function } fn The function to call on the event. The function takes
* one parameter: the event object.
*/
-Dygraph.prototype.addEvent = function addEvent(elem, type, fn) {
+Dygraph.addEvent = function addEvent(elem, type, fn) {
if (elem.addEventListener) {
elem.addEventListener(type, fn, false);
} else {
elem[type+fn] = function(){fn(window.event);};
elem.attachEvent('on'+type, elem[type+fn]);
}
+};
+
+/**
+ * @private
+ * Add an event handler. This event handler is kept until the graph is
+ * destroyed with a call to graph.destroy().
+ *
+ * @param { DOM element } elem The element to add the event to.
+ * @param { String } type The type of the event, e.g. 'click' or 'mousemove'.
+ * @param { Function } fn The function to call on the event. The function takes
+ * one parameter: the event object.
+ */
+Dygraph.prototype.addEvent = function addEvent(elem, type, fn) {
+ Dygraph.addEvent(elem, type, fn);
this.registeredEvents_.push({ elem : elem, type : type, fn : fn });
};
* @param { Function } fn The function to call on the event. The function takes
* one parameter: the event object.
*/
-Dygraph.prototype.removeEvent = function addEvent(elem, type, fn) {
+Dygraph.removeEvent = function addEvent(elem, type, fn) {
if (elem.removeEventListener) {
elem.removeEventListener(type, fn, false);
} else {
// DOM objects are shallowly-copied.
self[k] = o[k];
} else if (typeof(o[k]) == 'object') {
- if (typeof(self[k]) != 'object') {
+ if (typeof(self[k]) != 'object' || self[k] === null) {
self[k] = {};
}
Dygraph.updateDeep(self[k], o[k]);