4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/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
20 * A mixin providing highlight functionality for Ext.chart.series.Series.
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,
71 if (!me.highlight || !sprite || sprite._highlighted) {
75 sprite._anim.paused = true;
77 sprite._highlighted = true;
78 if (!sprite._defaults) {
79 sprite._defaults = Ext.apply({}, sprite.attr);
83 if (! (p in sprite._defaults)) {
84 sprite._defaults[p] = surface.availableAttrs[p];
86 from[p] = sprite._defaults[p];
88 if (Ext.isObject(opts[p])) {
91 Ext.apply(sprite._defaults[p], sprite.attr[p]);
92 Ext.apply(from[p], sprite._defaults[p]);
93 for (pi in sprite._defaults[p]) {
94 if (! (pi in opts[p])) {
95 to[p][pi] = from[p][pi];
97 to[p][pi] = opts[p][pi];
100 for (pi in opts[p]) {
101 if (! (pi in to[p])) {
102 to[p][pi] = opts[p][pi];
109 sprite._endStyle = to;
112 sprite._anim = Ext.create('Ext.fx.Anim', {
119 sprite.setAttributes(sprite._to, true);
123 <span id='Ext-chart-Highlight-method-unHighlightItem'> /**
124 </span> * Un-highlight any existing highlights
126 unHighlightItem: function() {
127 if (!this.highlight || !this.items) {
134 opts = me.highlightCfg,
135 animate = me.chart.animate,
139 for (; i < len; i++) {
143 sprite = items[i].sprite;
144 if (sprite && sprite._highlighted) {
146 sprite._anim.paused = true;
150 if (Ext.isObject(sprite._defaults[p])) {
152 Ext.apply(obj[p], sprite._defaults[p]);
155 obj[p] = sprite._defaults[p];
160 sprite._endStyle = obj;
161 sprite._anim = Ext.create('Ext.fx.Anim', {
168 sprite.setAttributes(obj, true);
170 delete sprite._highlighted;
171 //delete sprite._defaults;
176 cleanHighlights: function() {
177 if (!this.highlight) {
181 var group = this.group,
182 markerGroup = this.markerGroup,
185 for (l = group.getCount(); i < l; i++) {
186 delete group.getAt(i)._defaults;
189 for (l = markerGroup.getCount(); i < l; i++) {
190 delete markerGroup.getAt(i)._defaults;