Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / docs / source / Navigation.html
1 <!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.Navigation'>/**
2 </span> * @class Ext.chart.Navigation
3  *
4  * Handles panning and zooming capabilities.
5  * 
6  * @ignore
7  */
8 Ext.define('Ext.chart.Navigation', {
9
10     constructor: function() {
11         this.originalStore = this.store;
12     },
13     
14     //filters the store to the specified interval(s)
15     setZoom: function(zoomConfig) {
16         var me = this,
17             store = me.substore || me.store,
18             bbox = me.chartBBox,
19             len = store.getCount(),
20             from = (zoomConfig.x / bbox.width * len) &gt;&gt; 0,
21             to = Math.ceil(((zoomConfig.x + zoomConfig.width) / bbox.width * len)),
22             recFieldsLen, recFields = [], curField, json = [], obj;
23         
24         store.each(function(rec, i) {
25             if (i &lt; from || i &gt; to) {
26                 return;
27             }
28             obj = {};
29             //get all record field names in a simple array
30             if (!recFields.length) {
31                 rec.fields.each(function(f) {
32                     recFields.push(f.name);
33                 });
34                 recFieldsLen = recFields.length;
35             }
36             //append record values to an aggregation record
37             for (i = 0; i &lt; recFieldsLen; i++) {
38                 curField = recFields[i];
39                 obj[curField] = rec.get(curField);
40             }
41             json.push(obj);
42         });
43         me.store = me.substore = Ext.create('Ext.data.JsonStore', {
44             fields: recFields,
45             data: json
46         });
47         me.redraw(true);
48     },
49
50     restoreZoom: function() {
51         this.store = this.substore = this.originalStore;
52         this.redraw(true);
53     }
54     
55 });</pre></pre></body></html>