define optional parametr parentID for tooltip element

This commit is contained in:
Tsyren Ochirov 2012-06-28 11:00:35 +04:00
parent 1ea04ec428
commit d06d04ebed
2 changed files with 8 additions and 14 deletions

View File

@ -60,7 +60,6 @@ nv.render = function render(step) {
}; };
nv.render.queue = []; nv.render.queue = [];
nv.addGraph = function(obj) { nv.addGraph = function(obj) {
if (typeof arguments[0] === 'function') if (typeof arguments[0] === 'function')
obj = {generate: arguments[0], callback: arguments[1]}; obj = {generate: arguments[0], callback: arguments[1]};
@ -70,17 +69,13 @@ nv.addGraph = function(obj) {
if (!nv.render.active) nv.render(); if (!nv.render.active) nv.render();
}; };
nv.identity = function(d) { return d }; 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) { function daysInMonth(month,year) {
return (new Date(year, month+1, 0)).getDate(); return (new Date(year, month+1, 0)).getDate();
} };
function d3_time_range(floor, step, number) { function d3_time_range(floor, step, number) {
return function(t0, t1, dt) { return function(t0, t1, dt) {
@ -97,14 +92,12 @@ function d3_time_range(floor, step, number) {
} }
return times; return times;
}; };
} };
d3.time.monthEnd = function(date) { d3.time.monthEnd = function(date) {
return new Date(date.getFullYear(), date.getMonth(), 0); return new Date(date.getFullYear(), date.getMonth(), 0);
}; };
d3.time.monthEnds = d3_time_range(d3.time.monthEnd, function(date) { d3.time.monthEnds = d3_time_range(d3.time.monthEnd, function(date) {
date.setUTCDate(date.getUTCDate() + 1); date.setUTCDate(date.getUTCDate() + 1);
date.setDate(daysInMonth(date.getMonth() + 1, date.getFullYear())); date.setDate(daysInMonth(date.getMonth() + 1, date.getFullYear()));
@ -112,4 +105,3 @@ d3.time.monthEnds = d3_time_range(d3.time.monthEnd, function(date) {
return date.getMonth(); return date.getMonth();
} }
); );

View File

@ -8,7 +8,9 @@
var nvtooltip = window.nv.tooltip = {}; 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"); var container = document.createElement("div");
container.className = "nvtooltip"; container.className = "nvtooltip";
@ -16,7 +18,7 @@
gravity = gravity || 's'; gravity = gravity || 's';
dist = dist || 20; dist = dist || 20;
var body = document.getElementsByTagName("body")[0]; var body = parentId ? document.getElementById(parentId) : document.getElementsByTagName("body")[0];
container.innerHTML = content; container.innerHTML = content;
container.style.left = 1; container.style.left = 1;