From d06d04ebed8746aa2eddccc41cbca9b6aebfb137 Mon Sep 17 00:00:00 2001 From: Tsyren Ochirov Date: Thu, 28 Jun 2012 11:00:35 +0400 Subject: [PATCH] define optional parametr parentID for tooltip element --- src/core.js | 16 ++++------------ src/tooltip.js | 6 ++++-- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/core.js b/src/core.js index b2441c7..15e91cd 100644 --- a/src/core.js +++ b/src/core.js @@ -60,7 +60,6 @@ nv.render = function render(step) { }; nv.render.queue = []; - nv.addGraph = function(obj) { if (typeof arguments[0] === 'function') obj = {generate: arguments[0], callback: arguments[1]}; @@ -70,17 +69,13 @@ nv.addGraph = function(obj) { if (!nv.render.active) nv.render(); }; - nv.identity = function(d) { return d }; - -nv.strip = function(s) { - return s.replace(/(\s|&)/g,''); -} +nv.strip = function(s) { return s.replace(/(\s|&)/g,''); }; function daysInMonth(month,year) { return (new Date(year, month+1, 0)).getDate(); -} +}; function d3_time_range(floor, step, number) { return function(t0, t1, dt) { @@ -97,19 +92,16 @@ function d3_time_range(floor, step, number) { } return times; }; -} - +}; d3.time.monthEnd = function(date) { return new Date(date.getFullYear(), date.getMonth(), 0); }; - d3.time.monthEnds = d3_time_range(d3.time.monthEnd, function(date) { date.setUTCDate(date.getUTCDate() + 1); date.setDate(daysInMonth(date.getMonth() + 1, date.getFullYear())); }, function(date) { return date.getMonth(); } -); - +); \ No newline at end of file diff --git a/src/tooltip.js b/src/tooltip.js index 9da0062..953624d 100644 --- a/src/tooltip.js +++ b/src/tooltip.js @@ -8,7 +8,9 @@ var nvtooltip = window.nv.tooltip = {}; - nvtooltip.show = function(pos, content, gravity, dist) { + nvtooltip.show = function() { + var args = arguments; + var pos = args[0], content = args[1], gravity = args[2], dist = args[3], parentId = args[4]; var container = document.createElement("div"); container.className = "nvtooltip"; @@ -16,7 +18,7 @@ gravity = gravity || 's'; dist = dist || 20; - var body = document.getElementsByTagName("body")[0]; + var body = parentId ? document.getElementById(parentId) : document.getElementsByTagName("body")[0]; container.innerHTML = content; container.style.left = 1;