3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
16 * @class Ext.chart.Highlight
17 * A mixin providing highlight functionality for Ext.chart.series.Series.
19 Ext.define('Ext.chart.Highlight', {
21 /* Begin Definitions */
23 requires: ['Ext.fx.Anim'],
28 * Highlight the given series item.
29 * @param {Boolean/Object} Default's false. Can also be an object width style properties (i.e fill, stroke, radius)
30 * or just use default styles per series by setting highlight = true.
36 constructor: function(config) {
37 if (config.highlight) {
38 if (config.highlight !== true) { //is an object
39 this.highlightCfg = Ext.apply({}, config.highlight);
53 * Highlight the given series item.
54 * @param {Object} item Info about the item; same format as returned by #getItemForPoint.
56 highlightItem: function(item) {
63 opts = me.highlightCfg,
64 surface = me.chart.surface,
65 animate = me.chart.animate,
68 if (!me.highlight || !sprite || sprite._highlighted) {
72 sprite._anim.paused = true;
74 sprite._highlighted = true;
75 if (!sprite._defaults) {
76 sprite._defaults = Ext.apply({}, sprite.attr);
80 if (! (p in sprite._defaults)) {
81 sprite._defaults[p] = surface.availableAttrs[p];
83 from[p] = sprite._defaults[p];
85 if (Ext.isObject(opts[p])) {
88 Ext.apply(sprite._defaults[p], sprite.attr[p]);
89 Ext.apply(from[p], sprite._defaults[p]);
90 for (pi in sprite._defaults[p]) {
91 if (! (pi in opts[p])) {
92 to[p][pi] = from[p][pi];
94 to[p][pi] = opts[p][pi];
98 if (! (pi in to[p])) {
99 to[p][pi] = opts[p][pi];
106 sprite._endStyle = to;
109 sprite._anim = Ext.create('Ext.fx.Anim', {
116 sprite.setAttributes(sprite._to, true);
121 * Un-highlight any existing highlights
123 unHighlightItem: function() {
124 if (!this.highlight || !this.items) {
131 opts = me.highlightCfg,
132 animate = me.chart.animate,
136 for (; i < len; i++) {
140 sprite = items[i].sprite;
141 if (sprite && sprite._highlighted) {
143 sprite._anim.paused = true;
147 if (Ext.isObject(sprite._defaults[p])) {
149 Ext.apply(obj[p], sprite._defaults[p]);
152 obj[p] = sprite._defaults[p];
157 sprite._endStyle = obj;
158 sprite._anim = Ext.create('Ext.fx.Anim', {
165 sprite.setAttributes(obj, true);
167 delete sprite._highlighted;
168 //delete sprite._defaults;
173 cleanHighlights: function() {
174 if (!this.highlight) {
178 var group = this.group,
179 markerGroup = this.markerGroup,
182 for (l = group.getCount(); i < l; i++) {
183 delete group.getAt(i)._defaults;
186 for (l = markerGroup.getCount(); i < l; i++) {
187 delete markerGroup.getAt(i)._defaults;