]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix tooltip not shown for missing dataset 2789/head
authorAndré Wallat <awallat@users.noreply.github.com>
Thu, 16 Jun 2016 11:20:54 +0000 (13:20 +0200)
committerAndre Wallat <andre.wallat@wemove.com>
Tue, 28 Jun 2016 07:45:08 +0000 (09:45 +0200)
When two datasets are shown and they don't have the same x-coordinates, then the position of the tooltip is not calculated correctly, when using mode 'label' or 'dataset'. This fix checks if the position of every dataset exists, before it is used.

src/core/core.tooltip.js

index 6eb6b3a557a2a6c0d7f44661d8ff3b86f68042ec..589d4292b1a3f91e4c8717b4a5fa761ea901bf80 100755 (executable)
@@ -117,8 +117,10 @@ module.exports = function(Chart) {
                var x = 0,
                        y = 0;
                for (i = 0; i < xPositions.length; ++i) {
-                       x += xPositions[i];
-                       y += yPositions[i];
+                       if (xPositions[ i ]) {
+                               x += xPositions[i];
+                               y += yPositions[i];
+                       }
                }
 
                return {