Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / docs / source / Highlight.html
diff --git a/docs/source/Highlight.html b/docs/source/Highlight.html
new file mode 100644 (file)
index 0000000..67b8fe9
--- /dev/null
@@ -0,0 +1,180 @@
+<!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-chart.Highlight'>/**
+</span> * @class Ext.chart.Highlight
+ * @ignore
+ */
+Ext.define('Ext.chart.Highlight', {
+
+    /* Begin Definitions */
+
+    requires: ['Ext.fx.Anim'],
+
+    /* End Definitions */
+
+<span id='Ext-chart.Highlight-property-highlight'>    /**
+</span>     * Highlight the given series item.
+     * @param {Boolean|Object} Default's false. Can also be an object width style properties (i.e fill, stroke, radius) 
+     * or just use default styles per series by setting highlight = true.
+     */
+    highlight: false,
+
+    highlightCfg : null,
+
+    constructor: function(config) {
+        if (config.highlight) {
+            if (config.highlight !== true) { //is an object
+                this.highlightCfg = Ext.apply({}, config.highlight);
+            }
+            else {
+                this.highlightCfg = {
+                    fill: '#fdd',
+                    radius: 20,
+                    lineWidth: 5,
+                    stroke: '#f55'
+                };
+            }
+        }
+    },
+
+<span id='Ext-chart.Highlight-method-highlightItem'>    /**
+</span>     * Highlight the given series item.
+     * @param {Object} item Info about the item; same format as returned by #getItemForPoint.
+     */
+    highlightItem: function(item) {
+        if (!item) {
+            return;
+        }
+        
+        var me = this,
+            sprite = item.sprite,
+            opts = me.highlightCfg,
+            surface = me.chart.surface,
+            animate = me.chart.animate,
+            p,
+            from,
+            to,
+            pi;
+
+        if (!me.highlight || !sprite || sprite._highlighted) {
+            return;
+        }
+        if (sprite._anim) {
+            sprite._anim.paused = true;
+        }
+        sprite._highlighted = true;
+        if (!sprite._defaults) {
+            sprite._defaults = Ext.apply(sprite._defaults || {},
+            sprite.attr);
+            from = {};
+            to = {};
+            for (p in opts) {
+                if (! (p in sprite._defaults)) {
+                    sprite._defaults[p] = surface.availableAttrs[p];
+                }
+                from[p] = sprite._defaults[p];
+                to[p] = opts[p];
+                if (Ext.isObject(opts[p])) {
+                    from[p] = {};
+                    to[p] = {};
+                    Ext.apply(sprite._defaults[p], sprite.attr[p]);
+                    Ext.apply(from[p], sprite._defaults[p]);
+                    for (pi in sprite._defaults[p]) {
+                        if (! (pi in opts[p])) {
+                            to[p][pi] = from[p][pi];
+                        } else {
+                            to[p][pi] = opts[p][pi];
+                        }
+                    }
+                    for (pi in opts[p]) {
+                        if (! (pi in to[p])) {
+                            to[p][pi] = opts[p][pi];
+                        }
+                    }
+                }
+            }
+            sprite._from = from;
+            sprite._to = to;
+        }
+        if (animate) {
+            sprite._anim = Ext.create('Ext.fx.Anim', {
+                target: sprite,
+                from: sprite._from,
+                to: sprite._to,
+                duration: 150
+            });
+        } else {
+            sprite.setAttributes(sprite._to, true);
+        }
+    },
+
+<span id='Ext-chart.Highlight-method-unHighlightItem'>    /**
+</span>     * Un-highlight any existing highlights
+     */
+    unHighlightItem: function() {
+        if (!this.highlight || !this.items) {
+            return;
+        }
+
+        var me = this,
+            items = me.items,
+            len = items.length,
+            opts = me.highlightCfg,
+            animate = me.chart.animate,
+            i = 0,
+            obj,
+            p,
+            sprite;
+
+        for (; i &lt; len; i++) {
+            if (!items[i]) {
+                continue;
+            }
+            sprite = items[i].sprite;
+            if (sprite &amp;&amp; sprite._highlighted) {
+                if (sprite._anim) {
+                    sprite._anim.paused = true;
+                }
+                obj = {};
+                for (p in opts) {
+                    if (Ext.isObject(sprite._defaults[p])) {
+                        obj[p] = {};
+                        Ext.apply(obj[p], sprite._defaults[p]);
+                    }
+                    else {
+                        obj[p] = sprite._defaults[p];
+                    }
+                }
+                if (animate) {
+                    sprite._anim = Ext.create('Ext.fx.Anim', {
+                        target: sprite,
+                        to: obj,
+                        duration: 150
+                    });
+                }
+                else {
+                    sprite.setAttributes(obj, true);
+                }
+                delete sprite._highlighted;
+                //delete sprite._defaults;
+            }
+        }
+    },
+
+    cleanHighlights: function() {
+        if (!this.highlight) {
+            return;
+        }
+
+        var group = this.group,
+            markerGroup = this.markerGroup,
+            i = 0,
+            l;
+        for (l = group.getCount(); i &lt; l; i++) {
+            delete group.getAt(i)._defaults;
+        }
+        if (markerGroup) {
+            for (l = markerGroup.getCount(); i &lt; l; i++) {
+                delete markerGroup.getAt(i)._defaults;
+            }
+        }
+    }
+});</pre></pre></body></html>
\ No newline at end of file