Fixed badge position in statistics chart
authorMarcel Werk <burntime@woltlab.com>
Thu, 5 Jan 2017 15:48:23 +0000 (16:48 +0100)
committerMarcel Werk <burntime@woltlab.com>
Thu, 5 Jan 2017 15:49:33 +0000 (16:49 +0100)
wcfsetup/install/files/acp/js/WCF.ACP.js

index 477f3a4f152af0a8de5faea6f6241ced2524cdac..64bb1ff5836d1ee1c979c1b8943abee704a6bd51 100644 (file)
@@ -2469,7 +2469,7 @@ WCF.ACP.Stat.Chart = Class.extend({
                                tickFormatter: function(val) {
                                        return WCF.String.addThousandsSeparator(val);
                                }
-                       },
+                       }
                };
                
                var $data = [ ];
@@ -2484,13 +2484,24 @@ WCF.ACP.Stat.Chart = Class.extend({
                
                $.plot("#chart", $data, options);
                
-               $("#chart").on("plothover", function(event, pos, item) {
-                       if (item) {
-                               $("#chartTooltip").html(item.series.xaxis.tickFormatter(item.datapoint[0], item.series.xaxis) + ', ' + WCF.String.formatNumeric(item.datapoint[1]) + ' ' + item.series.label).css({top: item.pageY + 5, left: item.pageX + 5}).wcfFadeIn();
-                       }
-                       else {
-                               $("#chartTooltip").hide();
-                       }
+               require(['Ui/Alignment'], function (UiAlignment) {
+                       var span = elCreate('span');
+                       span.style.setProperty('position', 'absolute', '');
+                       document.body.appendChild(span);
+                       $("#chart").on("plothover", function(event, pos, item) {
+                               if (item) {
+                                       span.style.setProperty('top', item.pageY + 'px', '');
+                                       span.style.setProperty('left', item.pageX + 'px', '');
+                                       $("#chartTooltip").html(item.series.xaxis.tickFormatter(item.datapoint[0], item.series.xaxis) + ', ' + WCF.String.formatNumeric(item.datapoint[1]) + ' ' + item.series.label).show();
+                                       UiAlignment.set($("#chartTooltip")[0], span, {
+                                               verticalOffset: 5,
+                                               horizontal: 'center'
+                                       });
+                               }
+                               else {
+                                       $("#chartTooltip").hide();
+                               }
+                       });
                });
                
                if (!$data.length) {