Issue #251 Fixed tooltip calculations on bulletChart

master-patched
Bob Monteverde 12 years ago
parent d470771777
commit 7e66e3c53d

@ -1230,8 +1230,8 @@ nv.models.bulletChart = function() {
, tickFormat = null
, tooltips = true
, tooltip = function(key, x, y, e, graph) {
return '<h3>' + e.label + '</h3>' +
'<p>' + e.value + '</p>'
return '<h3>' + x + '</h3>' +
'<p>' + y + '</p>'
}
, noData = 'No Data Available.'
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
@ -1245,12 +1245,9 @@ nv.models.bulletChart = function() {
//------------------------------------------------------------
var showTooltip = function(e, offsetElement) {
var offsetElement = document.getElementById('chart'),
left = e.pos[0] + offsetElement.offsetLeft + margin.left,
top = e.pos[1] + offsetElement.offsetTop + margin.top;
var content = '<h3>' + e.label + '</h3>' +
'<p>' + e.value + '</p>';
var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ) + margin.left,
top = e.pos[1] + ( offsetElement.offsetTop || 0) + margin.top,
content = tooltip(e.key, e.label, e.value, e, chart);
nv.tooltip.show([left, top], content, e.value < 0 ? 'e' : 'w', null, offsetElement);
};
@ -1381,7 +1378,7 @@ nv.models.bulletChart = function() {
// Compute the tick format.
var format = tickFormat || x1.tickFormat(8);
var format = tickFormat || x1.tickFormat( availableWidth / 100 );
// Update the tick groups.
var tick = g.selectAll('g.nv-tick')
@ -1430,6 +1427,7 @@ nv.models.bulletChart = function() {
//------------------------------------------------------------
dispatch.on('tooltipShow', function(e) {
e.key = data[0].title;
if (tooltips) showTooltip(e, that.parentNode);
});

10
nv.d3.min.js vendored

File diff suppressed because one or more lines are too long

@ -22,8 +22,8 @@ nv.models.bulletChart = function() {
, tickFormat = null
, tooltips = true
, tooltip = function(key, x, y, e, graph) {
return '<h3>' + e.label + '</h3>' +
'<p>' + e.value + '</p>'
return '<h3>' + x + '</h3>' +
'<p>' + y + '</p>'
}
, noData = 'No Data Available.'
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
@ -37,12 +37,9 @@ nv.models.bulletChart = function() {
//------------------------------------------------------------
var showTooltip = function(e, offsetElement) {
var offsetElement = document.getElementById('chart'),
left = e.pos[0] + offsetElement.offsetLeft + margin.left,
top = e.pos[1] + offsetElement.offsetTop + margin.top;
var content = '<h3>' + e.label + '</h3>' +
'<p>' + e.value + '</p>';
var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ) + margin.left,
top = e.pos[1] + ( offsetElement.offsetTop || 0) + margin.top,
content = tooltip(e.key, e.label, e.value, e, chart);
nv.tooltip.show([left, top], content, e.value < 0 ? 'e' : 'w', null, offsetElement);
};
@ -173,7 +170,7 @@ nv.models.bulletChart = function() {
// Compute the tick format.
var format = tickFormat || x1.tickFormat(8);
var format = tickFormat || x1.tickFormat( availableWidth / 100 );
// Update the tick groups.
var tick = g.selectAll('g.nv-tick')
@ -222,6 +219,7 @@ nv.models.bulletChart = function() {
//------------------------------------------------------------
dispatch.on('tooltipShow', function(e) {
e.key = data[0].title;
if (tooltips) showTooltip(e, that.parentNode);
});

Loading…
Cancel
Save