]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
backport fix for ExtJS pie chart tooltip for 0% entries
authorDominik Csapak <d.csapak@proxmox.com>
Wed, 29 May 2019 11:36:04 +0000 (13:36 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 31 May 2019 08:58:11 +0000 (10:58 +0200)
this fixes bug EXTJS_18900 where the tooltip of a piechart was always
shown for the first data entry with 0 percent of the pie chart

the relevant lines for the fix are
...
if (a === b) {
    return false;
}
...

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Toolkit.js

index d5761743f00dda8ef18485e9ecc669ed3d63932e..abdeb64c931f1c6171fff268407df41c703bb9fc 100644 (file)
@@ -208,6 +208,46 @@ Ext.define('EXTJS_23846.Gesture', {
     }
 });
 
+Ext.define('EXTJS_18900.Pie', {
+    override: 'Ext.chart.series.Pie',
+
+    // from 6.0.2
+    betweenAngle: function (x, a, b) {
+        var pp = Math.PI * 2,
+            offset = this.rotationOffset;
+
+        if (a === b) {
+            return false;
+        }
+
+        if (!this.getClockwise()) {
+            x *= -1;
+            a *= -1;
+            b *= -1;
+            a -= offset;
+            b -= offset;
+        } else {
+            a += offset;
+            b += offset;
+        }
+
+        x -= a;
+        b -= a;
+
+        // Normalize, so that both x and b are in the [0,360) interval.
+        x %= pp;
+        b %= pp;
+        x += pp;
+        b += pp;
+        x %= pp;
+        b %= pp;
+
+        // Because 360 * n angles will be normalized to 0,
+        // we need to treat b === 0 as a special case.
+        return x < b || b === 0;
+    },
+});
+
 // we always want the number in x.y format and never in, e.g., x,y
 Ext.define('PVE.form.field.Number', {
     override: 'Ext.form.field.Number',