4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-chart-Highlight'>/**
19 </span> * @class Ext.chart.Highlight
22 Ext.define('Ext.chart.Highlight', {
24 /* Begin Definitions */
26 requires: ['Ext.fx.Anim'],
30 <span id='Ext-chart-Highlight-property-highlight'> /**
31 </span> * Highlight the given series item.
32 * @param {Boolean|Object} Default's false. Can also be an object width style properties (i.e fill, stroke, radius)
33 * or just use default styles per series by setting highlight = true.
39 constructor: function(config) {
40 if (config.highlight) {
41 if (config.highlight !== true) { //is an object
42 this.highlightCfg = Ext.apply({}, config.highlight);
55 <span id='Ext-chart-Highlight-method-highlightItem'> /**
56 </span> * Highlight the given series item.
57 * @param {Object} item Info about the item; same format as returned by #getItemForPoint.
59 highlightItem: function(item) {
66 opts = me.highlightCfg,
67 surface = me.chart.surface,
68 animate = me.chart.animate,
74 if (!me.highlight || !sprite || sprite._highlighted) {
78 sprite._anim.paused = true;
80 sprite._highlighted = true;
81 if (!sprite._defaults) {
82 sprite._defaults = Ext.apply(sprite._defaults || {},
87 if (! (p in sprite._defaults)) {
88 sprite._defaults[p] = surface.availableAttrs[p];
90 from[p] = sprite._defaults[p];
92 if (Ext.isObject(opts[p])) {
95 Ext.apply(sprite._defaults[p], sprite.attr[p]);
96 Ext.apply(from[p], sprite._defaults[p]);
97 for (pi in sprite._defaults[p]) {
98 if (! (pi in opts[p])) {
99 to[p][pi] = from[p][pi];
101 to[p][pi] = opts[p][pi];
104 for (pi in opts[p]) {
105 if (! (pi in to[p])) {
106 to[p][pi] = opts[p][pi];
115 sprite._anim = Ext.create('Ext.fx.Anim', {
122 sprite.setAttributes(sprite._to, true);
126 <span id='Ext-chart-Highlight-method-unHighlightItem'> /**
127 </span> * Un-highlight any existing highlights
129 unHighlightItem: function() {
130 if (!this.highlight || !this.items) {
137 opts = me.highlightCfg,
138 animate = me.chart.animate,
144 for (; i < len; i++) {
148 sprite = items[i].sprite;
149 if (sprite && sprite._highlighted) {
151 sprite._anim.paused = true;
155 if (Ext.isObject(sprite._defaults[p])) {
157 Ext.apply(obj[p], sprite._defaults[p]);
160 obj[p] = sprite._defaults[p];
164 sprite._anim = Ext.create('Ext.fx.Anim', {
171 sprite.setAttributes(obj, true);
173 delete sprite._highlighted;
174 //delete sprite._defaults;
179 cleanHighlights: function() {
180 if (!this.highlight) {
184 var group = this.group,
185 markerGroup = this.markerGroup,
188 for (l = group.getCount(); i < l; i++) {
189 delete group.getAt(i)._defaults;
192 for (l = markerGroup.getCount(); i < l; i++) {
193 delete markerGroup.getAt(i)._defaults;