From 46033a06cf47d3012827da04aab8f184bd9f1547 Mon Sep 17 00:00:00 2001 From: Itay Neeman Date: Sat, 14 Jul 2012 12:46:14 -0700 Subject: [PATCH] Add e.pointIndex to all chart tooltip calculations --- examples/discreteBarChart.html | 4 ++-- src/models/cumulativeLineChart.js | 4 ++-- src/models/discreteBarChart.js | 4 ++-- src/models/lineChart.js | 4 ++-- src/models/lineWithFisheyeChart.js | 4 ++-- src/models/lineWithFocusChart.js | 4 ++-- src/models/multiBarChart.js | 4 ++-- src/models/multiBarHorizontalChart.js | 4 ++-- src/models/scatterChart.js | 4 ++-- src/models/scatterFisheyeChart.js | 4 ++-- src/models/stackedAreaChart.js | 4 ++-- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/examples/discreteBarChart.html b/examples/discreteBarChart.html index 57d24c6..4484558 100644 --- a/examples/discreteBarChart.html +++ b/examples/discreteBarChart.html @@ -97,7 +97,7 @@ nv.addGraph(function() { .x(function(d) { return d.label }) .y(function(d) { return d.value }) .rotateLabels(-45) - //.staggerLabels(true) + .staggerLabels(true) //.staggerLabels(historicalBarChart[0].values.length > 8) .tooltips(false) .showValues(true) @@ -107,7 +107,7 @@ nv.addGraph(function() { .transition().duration(500) .call(chart); - //nv.utils.windowResize(chart.update); + nv.utils.windowResize(chart.update); return chart; }); diff --git a/src/models/cumulativeLineChart.js b/src/models/cumulativeLineChart.js index 5cab315..a2fdbb2 100644 --- a/src/models/cumulativeLineChart.js +++ b/src/models/cumulativeLineChart.js @@ -42,8 +42,8 @@ nv.models.cumulativeLineChart = function() { var showTooltip = function(e, offsetElement) { var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(lines.x()(e.point)), - y = yAxis.tickFormat()(lines.y()(e.point)), + x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), + y = yAxis.tickFormat()(lines.y()(e.point, e.pointIndex)), content = tooltip(e.series.key, x, y, e, chart); nv.tooltip.show([left, top], content); diff --git a/src/models/discreteBarChart.js b/src/models/discreteBarChart.js index 2a8c3fd..cbabf2f 100644 --- a/src/models/discreteBarChart.js +++ b/src/models/discreteBarChart.js @@ -27,8 +27,8 @@ nv.models.discreteBarChart = function() { var showTooltip = function(e, offsetElement) { var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(discretebar.x()(e.point)), - y = yAxis.tickFormat()(discretebar.y()(e.point)), + x = xAxis.tickFormat()(discretebar.x()(e.point, e.pointIndex)), + y = yAxis.tickFormat()(discretebar.y()(e.point, e.pointIndex)), content = tooltip(e.series.key, x, y, e, chart); nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's'); diff --git a/src/models/lineChart.js b/src/models/lineChart.js index e0c36e4..65fd49c 100644 --- a/src/models/lineChart.js +++ b/src/models/lineChart.js @@ -31,8 +31,8 @@ nv.models.lineChart = function() { var showTooltip = function(e, offsetElement) { var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(lines.x()(e.point)), - y = yAxis.tickFormat()(lines.y()(e.point)), + x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), + y = yAxis.tickFormat()(lines.y()(e.point, e.pointIndex)), content = tooltip(e.series.key, x, y, e, chart); nv.tooltip.show([left, top], content); diff --git a/src/models/lineWithFisheyeChart.js b/src/models/lineWithFisheyeChart.js index cfdf71b..3d2636d 100644 --- a/src/models/lineWithFisheyeChart.js +++ b/src/models/lineWithFisheyeChart.js @@ -30,8 +30,8 @@ nv.models.lineChart = function() { var showTooltip = function(e, offsetElement) { var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(lines.x()(e.point)), - y = yAxis.tickFormat()(lines.y()(e.point)), + x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), + y = yAxis.tickFormat()(lines.y()(e.point, e.pointIndex)), content = tooltip(e.series.key, x, y, e, chart); nv.tooltip.show([left, top], content); diff --git a/src/models/lineWithFocusChart.js b/src/models/lineWithFocusChart.js index 84d0691..c038f0b 100644 --- a/src/models/lineWithFocusChart.js +++ b/src/models/lineWithFocusChart.js @@ -31,8 +31,8 @@ nv.models.lineWithFocusChart = function() { var showTooltip = function(e, offsetElement) { var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(lines.x()(e.point)), - y = yAxis.tickFormat()(lines.y()(e.point)), + x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), + y = yAxis.tickFormat()(lines.y()(e.point, e.pointIndex)), content = tooltip(e.series.key, x, y, e, chart); nv.tooltip.show([left, top], content); diff --git a/src/models/multiBarChart.js b/src/models/multiBarChart.js index e22f8e8..189c9c3 100644 --- a/src/models/multiBarChart.js +++ b/src/models/multiBarChart.js @@ -36,8 +36,8 @@ nv.models.multiBarChart = function() { var showTooltip = function(e, offsetElement) { var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(multibar.x()(e.point)), - y = yAxis.tickFormat()(multibar.y()(e.point)), + x = xAxis.tickFormat()(multibar.x()(e.point, e.pointIndex)), + y = yAxis.tickFormat()(multibar.y()(e.point, e.pointIndex)), content = tooltip(e.series.key, x, y, e, chart); nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's'); diff --git a/src/models/multiBarHorizontalChart.js b/src/models/multiBarHorizontalChart.js index 8b8a2e2..81af759 100644 --- a/src/models/multiBarHorizontalChart.js +++ b/src/models/multiBarHorizontalChart.js @@ -28,8 +28,8 @@ nv.models.multiBarHorizontalChart = function() { var showTooltip = function(e, offsetElement) { var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(multibar.x()(e.point)), - y = yAxis.tickFormat()(multibar.y()(e.point)), + x = xAxis.tickFormat()(multibar.x()(e.point, e.pointIndex)), + y = yAxis.tickFormat()(multibar.y()(e.point, e.pointIndex)), content = tooltip(e.series.key, x, y, e, chart); nv.tooltip.show([left, top], content, e.value < 0 ? 'e' : 'w'); diff --git a/src/models/scatterChart.js b/src/models/scatterChart.js index 99fedd9..79c05a3 100644 --- a/src/models/scatterChart.js +++ b/src/models/scatterChart.js @@ -54,8 +54,8 @@ nv.models.scatterChart = function() { topX = y.range()[0] + margin.top + ( offsetElement.offsetTop || 0), leftY = x.range()[0] + margin.left + ( offsetElement.offsetLeft || 0 ), topY = e.pos[1] + ( offsetElement.offsetTop || 0), - xVal = xAxis.tickFormat()(scatter.x()(e.point)), - yVal = yAxis.tickFormat()(scatter.y()(e.point)), + xVal = xAxis.tickFormat()(scatter.x()(e.point, e.pointIndex)), + yVal = yAxis.tickFormat()(scatter.y()(e.point, e.pointIndex)), contentX = tooltipX(e.series.key, xVal, yVal, e, chart), contentY = tooltipY(e.series.key, xVal, yVal, e, chart); //content = tooltip(e.series.key, xVal, yVal, e, chart); diff --git a/src/models/scatterFisheyeChart.js b/src/models/scatterFisheyeChart.js index 02e0edf..9772f8a 100644 --- a/src/models/scatterFisheyeChart.js +++ b/src/models/scatterFisheyeChart.js @@ -39,8 +39,8 @@ nv.models.scatterFisheyeChart = function() { topX = y.range()[0] + margin.top + ( offsetElement.offsetTop || 0), leftY = x.range()[0] + margin.left + ( offsetElement.offsetLeft || 0 ), topY = e.pos[1] + ( offsetElement.offsetTop || 0), - xVal = xAxis.tickFormat()(scatter.x()(e.point)), - yVal = yAxis.tickFormat()(scatter.y()(e.point)), + xVal = xAxis.tickFormat()(scatter.x()(e.point, e.pointIndex)), + yVal = yAxis.tickFormat()(scatter.y()(e.point, e.pointIndex)), contentX = tooltipX(e.series.key, xVal, yVal, e, chart), contentY = tooltipY(e.series.key, xVal, yVal, e, chart); //content = tooltip(e.series.key, xVal, yVal, e, chart); diff --git a/src/models/stackedAreaChart.js b/src/models/stackedAreaChart.js index 54a8d36..3a0834a 100644 --- a/src/models/stackedAreaChart.js +++ b/src/models/stackedAreaChart.js @@ -40,8 +40,8 @@ nv.models.stackedAreaChart = function() { var showTooltip = function(e, offsetElement) { var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(stacked.x()(e.point)), - y = yAxis.tickFormat()(stacked.y()(e.point)), + x = xAxis.tickFormat()(stacked.x()(e.point, e.pointIndex)), + y = yAxis.tickFormat()(stacked.y()(e.point, e.pointIndex)), content = tooltip(e.series.key, x, y, e, chart); nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's');