]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Call tooltip update even when tooltip has no active elements
authorTanner Linsley <tannerlinsley@gmail.com>
Sat, 31 Oct 2015 22:07:36 +0000 (16:07 -0600)
committerTanner Linsley <tannerlinsley@gmail.com>
Sat, 31 Oct 2015 22:07:36 +0000 (16:07 -0600)
src/core/core.controller.js

index 915ae85121d7cddfd6cecd454f8457aa0a040827..c65f7a12bc1bf7700376abad281709556434dd04 100644 (file)
                        }
                },
                buildScales: function buildScales() {
-                       // Map of scale ID to scale object so we can lookup later 
+                       // Map of scale ID to scale object so we can lookup later
                        this.scales = {};
 
                        // Build the x axes
 
                        // Find Active Elements for hover and tooltips
                        if (e.type == 'mouseout') {
-                               this.active = this.tooltipActive = [];
+                               this.active = this.lastActive = [];
+                               this.tooltipActive = this.lastTooltipActive = [];
                        } else {
                                this.active = function() {
                                        switch (this.options.hover.mode) {
                                                _active: this.tooltipActive,
                                        });
 
-                                       this.tooltip.update();
                                } else {
                                        // Inactive
                                        this.tooltip._model.opacity = 0;
                                }
+                               this.tooltip.update();
                        }
 
                        // Hover animations
                                }, this);
 
                                // If entering, leaving, or changing elements, animate the change via pivot
-                               if ((!this.lastActive.length && this.active.length) ||
-                                       (this.lastActive.length && !this.active.length) ||
-                                       (this.lastActive.length && this.active.length && changed) ||
-                                       (!this.lastTooltipActive.length && this.tooltipActive.length) ||
-                                       (this.lastTooltipActive.length && !this.tooltipActive.length) ||
-                                       (this.lastTooltipActive.length && this.tooltipActive.length && changed)) {
+                               if ((this.lastActive.length !== this.active.length) ||
+                                       (this.lastActive.length === this.active.length && changed) ||
+                                       (this.lastTooltipActive.length !== this.tooltipActive.length) ||
+                                       (this.lastTooltipActive.length === this.tooltipActive.length && changed)) {
 
                                        this.stop();
+                                       console.log('render');
 
-                                       // We only need to render at this point. Updating will cause scales to be recomputed generating flicker & using more 
+                                       // We only need to render at this point. Updating will cause scales to be recomputed generating flicker & using more
                                        // memory than necessary.
                                        this.render(this.options.hover.animationDuration, true);
                                }