Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / docs / source / Navigation.html
1 <!DOCTYPE html>
2 <html>
3 <head>
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; }
10   </style>
11   <script type="text/javascript">
12     function highlight() {
13       document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
14     }
15   </script>
16 </head>
17 <body onload="prettyPrint(); highlight();">
18   <pre class="prettyprint lang-js"><span id='Ext-chart-Navigation'>/**
19 </span> * @class Ext.chart.Navigation
20  *
21  * Handles panning and zooming capabilities.
22  * 
23  * @ignore
24  */
25 Ext.define('Ext.chart.Navigation', {
26
27     constructor: function() {
28         this.originalStore = this.store;
29     },
30     
31     //filters the store to the specified interval(s)
32     setZoom: function(zoomConfig) {
33         var me = this,
34             store = me.substore || me.store,
35             bbox = me.chartBBox,
36             len = store.getCount(),
37             from = (zoomConfig.x / bbox.width * len) &gt;&gt; 0,
38             to = Math.ceil(((zoomConfig.x + zoomConfig.width) / bbox.width * len)),
39             recFieldsLen, recFields = [], curField, json = [], obj;
40         
41         store.each(function(rec, i) {
42             if (i &lt; from || i &gt; to) {
43                 return;
44             }
45             obj = {};
46             //get all record field names in a simple array
47             if (!recFields.length) {
48                 rec.fields.each(function(f) {
49                     recFields.push(f.name);
50                 });
51                 recFieldsLen = recFields.length;
52             }
53             //append record values to an aggregation record
54             for (i = 0; i &lt; recFieldsLen; i++) {
55                 curField = recFields[i];
56                 obj[curField] = rec.get(curField);
57             }
58             json.push(obj);
59         });
60         me.store = me.substore = Ext.create('Ext.data.JsonStore', {
61             fields: recFields,
62             data: json
63         });
64         me.redraw(true);
65     },
66
67     restoreZoom: function() {
68         this.store = this.substore = this.originalStore;
69         this.redraw(true);
70     }
71     
72 });</pre>
73 </body>
74 </html>