Bienvenue sur PostGIS.fr

Bienvenue sur PostGIS.fr , le site de la communauté des utilisateurs francophones de PostGIS.

PostGIS ajoute le support d'objets géographique à la base de données PostgreSQL. En effet, PostGIS "spatialise" le serverur PostgreSQL, ce qui permet de l'utiliser comme une base de données SIG.

Maintenu à jour, en fonction de nos disponibilités et des diverses sorties des outils que nous testons, nous vous proposons l'ensemble de nos travaux publiés en langue française.

source: trunk/workshop-routing-foss4g/web/ext/pkgs/pkg-charts-debug.js @ 76

Revision 76, 64.9 KB checked in by djay, 12 years ago (diff)

Ajout du répertoire web

  • Property svn:executable set to *
Line 
1/*!
2 * Ext JS Library 3.4.0
3 * Copyright(c) 2006-2011 Sencha Inc.
4 * licensing@sencha.com
5 * http://www.sencha.com/license
6 */
7/*! SWFObject v2.2 <http://code.google.com/p/swfobject/>
8    is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
9*/
10
11var swfobject = function() {
12   
13    var UNDEF = "undefined",
14        OBJECT = "object",
15        SHOCKWAVE_FLASH = "Shockwave Flash",
16        SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
17        FLASH_MIME_TYPE = "application/x-shockwave-flash",
18        EXPRESS_INSTALL_ID = "SWFObjectExprInst",
19        ON_READY_STATE_CHANGE = "onreadystatechange",
20       
21        win = window,
22        doc = document,
23        nav = navigator,
24       
25        plugin = false,
26        domLoadFnArr = [main],
27        regObjArr = [],
28        objIdArr = [],
29        listenersArr = [],
30        storedAltContent,
31        storedAltContentId,
32        storedCallbackFn,
33        storedCallbackObj,
34        isDomLoaded = false,
35        isExpressInstallActive = false,
36        dynamicStylesheet,
37        dynamicStylesheetMedia,
38        autoHideShow = true,
39   
40    /* Centralized function for browser feature detection
41        - User agent string detection is only used when no good alternative is possible
42        - Is executed directly for optimal performance
43    */ 
44    ua = function() {
45        var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
46            u = nav.userAgent.toLowerCase(),
47            p = nav.platform.toLowerCase(),
48            windows = p ? (/win/).test(p) : /win/.test(u),
49            mac = p ? (/mac/).test(p) : /mac/.test(u),
50            webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
51            ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html
52            playerVersion = [0,0,0],
53            d = null;
54        if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
55            d = nav.plugins[SHOCKWAVE_FLASH].description;
56            if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
57                plugin = true;
58                ie = false; // cascaded feature detection for Internet Explorer
59                d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
60                playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
61                playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
62                playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0;
63            }
64        }
65        else if (typeof win.ActiveXObject != UNDEF) {
66            try {
67                var a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
68                if (a) { // a will return null when ActiveX is disabled
69                    d = a.GetVariable("$version");
70                    if (d) {
71                        ie = true; // cascaded feature detection for Internet Explorer
72                        d = d.split(" ")[1].split(",");
73                        playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
74                    }
75                }
76            }
77            catch(e) {}
78        }
79        return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac };
80    }(),
81   
82    /* Cross-browser onDomLoad
83        - Will fire an event as soon as the DOM of a web page is loaded
84        - Internet Explorer workaround based on Diego Perini's solution: http://javascript.nwbox.com/IEContentLoaded/
85        - Regular onload serves as fallback
86    */ 
87    onDomLoad = function() {
88        if (!ua.w3) { return; }
89        if ((typeof doc.readyState != UNDEF && doc.readyState == "complete") || (typeof doc.readyState == UNDEF && (doc.getElementsByTagName("body")[0] || doc.body))) { // function is fired after onload, e.g. when script is inserted dynamically
90            callDomLoadFunctions();
91        }
92        if (!isDomLoaded) {
93            if (typeof doc.addEventListener != UNDEF) {
94                doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, false);
95            }       
96            if (ua.ie && ua.win) {
97                doc.attachEvent(ON_READY_STATE_CHANGE, function() {
98                    if (doc.readyState == "complete") {
99                        doc.detachEvent(ON_READY_STATE_CHANGE, arguments.callee);
100                        callDomLoadFunctions();
101                    }
102                });
103                if (win == top) { // if not inside an iframe
104                    (function(){
105                        if (isDomLoaded) { return; }
106                        try {
107                            doc.documentElement.doScroll("left");
108                        }
109                        catch(e) {
110                            setTimeout(arguments.callee, 0);
111                            return;
112                        }
113                        callDomLoadFunctions();
114                    })();
115                }
116            }
117            if (ua.wk) {
118                (function(){
119                    if (isDomLoaded) { return; }
120                    if (!(/loaded|complete/).test(doc.readyState)) {
121                        setTimeout(arguments.callee, 0);
122                        return;
123                    }
124                    callDomLoadFunctions();
125                })();
126            }
127            addLoadEvent(callDomLoadFunctions);
128        }
129    }();
130   
131    function callDomLoadFunctions() {
132        if (isDomLoaded) { return; }
133        try { // test if we can really add/remove elements to/from the DOM; we don't want to fire it too early
134            var t = doc.getElementsByTagName("body")[0].appendChild(createElement("span"));
135            t.parentNode.removeChild(t);
136        }
137        catch (e) { return; }
138        isDomLoaded = true;
139        var dl = domLoadFnArr.length;
140        for (var i = 0; i < dl; i++) {
141            domLoadFnArr[i]();
142        }
143    }
144   
145    function addDomLoadEvent(fn) {
146        if (isDomLoaded) {
147            fn();
148        }
149        else { 
150            domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+
151        }
152    }
153   
154    /* Cross-browser onload
155        - Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/
156        - Will fire an event as soon as a web page including all of its assets are loaded
157     */
158    function addLoadEvent(fn) {
159        if (typeof win.addEventListener != UNDEF) {
160            win.addEventListener("load", fn, false);
161        }
162        else if (typeof doc.addEventListener != UNDEF) {
163            doc.addEventListener("load", fn, false);
164        }
165        else if (typeof win.attachEvent != UNDEF) {
166            addListener(win, "onload", fn);
167        }
168        else if (typeof win.onload == "function") {
169            var fnOld = win.onload;
170            win.onload = function() {
171                fnOld();
172                fn();
173            };
174        }
175        else {
176            win.onload = fn;
177        }
178    }
179   
180    /* Main function
181        - Will preferably execute onDomLoad, otherwise onload (as a fallback)
182    */
183    function main() { 
184        if (plugin) {
185            testPlayerVersion();
186        }
187        else {
188            matchVersions();
189        }
190    }
191   
192    /* Detect the Flash Player version for non-Internet Explorer browsers
193        - Detecting the plug-in version via the object element is more precise than using the plugins collection item's description:
194          a. Both release and build numbers can be detected
195          b. Avoid wrong descriptions by corrupt installers provided by Adobe
196          c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports
197        - Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available
198    */
199    function testPlayerVersion() {
200        var b = doc.getElementsByTagName("body")[0];
201        var o = createElement(OBJECT);
202        o.setAttribute("type", FLASH_MIME_TYPE);
203        var t = b.appendChild(o);
204        if (t) {
205            var counter = 0;
206            (function(){
207                if (typeof t.GetVariable != UNDEF) {
208                    var d = t.GetVariable("$version");
209                    if (d) {
210                        d = d.split(" ")[1].split(",");
211                        ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
212                    }
213                }
214                else if (counter < 10) {
215                    counter++;
216                    setTimeout(arguments.callee, 10);
217                    return;
218                }
219                b.removeChild(o);
220                t = null;
221                matchVersions();
222            })();
223        }
224        else {
225            matchVersions();
226        }
227    }
228   
229    /* Perform Flash Player and SWF version matching; static publishing only
230    */
231    function matchVersions() {
232        var rl = regObjArr.length;
233        if (rl > 0) {
234            for (var i = 0; i < rl; i++) { // for each registered object element
235                var id = regObjArr[i].id;
236                var cb = regObjArr[i].callbackFn;
237                var cbObj = {success:false, id:id};
238                if (ua.pv[0] > 0) {
239                    var obj = getElementById(id);
240                    if (obj) {
241                        if (hasPlayerVersion(regObjArr[i].swfVersion) && !(ua.wk && ua.wk < 312)) { // Flash Player version >= published SWF version: Houston, we have a match!
242                            setVisibility(id, true);
243                            if (cb) {
244                                cbObj.success = true;
245                                cbObj.ref = getObjectById(id);
246                                cb(cbObj);
247                            }
248                        }
249                        else if (regObjArr[i].expressInstall && canExpressInstall()) { // show the Adobe Express Install dialog if set by the web page author and if supported
250                            var att = {};
251                            att.data = regObjArr[i].expressInstall;
252                            att.width = obj.getAttribute("width") || "0";
253                            att.height = obj.getAttribute("height") || "0";
254                            if (obj.getAttribute("class")) { att.styleclass = obj.getAttribute("class"); }
255                            if (obj.getAttribute("align")) { att.align = obj.getAttribute("align"); }
256                            // parse HTML object param element's name-value pairs
257                            var par = {};
258                            var p = obj.getElementsByTagName("param");
259                            var pl = p.length;
260                            for (var j = 0; j < pl; j++) {
261                                if (p[j].getAttribute("name").toLowerCase() != "movie") {
262                                    par[p[j].getAttribute("name")] = p[j].getAttribute("value");
263                                }
264                            }
265                            showExpressInstall(att, par, id, cb);
266                        }
267                        else { // Flash Player and SWF version mismatch or an older Webkit engine that ignores the HTML object element's nested param elements: display alternative content instead of SWF
268                            displayAltContent(obj);
269                            if (cb) { cb(cbObj); }
270                        }
271                    }
272                }
273                else {  // if no Flash Player is installed or the fp version cannot be detected we let the HTML object element do its job (either show a SWF or alternative content)
274                    setVisibility(id, true);
275                    if (cb) {
276                        var o = getObjectById(id); // test whether there is an HTML object element or not
277                        if (o && typeof o.SetVariable != UNDEF) { 
278                            cbObj.success = true;
279                            cbObj.ref = o;
280                        }
281                        cb(cbObj);
282                    }
283                }
284            }
285        }
286    }
287   
288    function getObjectById(objectIdStr) {
289        var r = null;
290        var o = getElementById(objectIdStr);
291        if (o && o.nodeName == "OBJECT") {
292            if (typeof o.SetVariable != UNDEF) {
293                r = o;
294            }
295            else {
296                var n = o.getElementsByTagName(OBJECT)[0];
297                if (n) {
298                    r = n;
299                }
300            }
301        }
302        return r;
303    }
304   
305    /* Requirements for Adobe Express Install
306        - only one instance can be active at a time
307        - fp 6.0.65 or higher
308        - Win/Mac OS only
309        - no Webkit engines older than version 312
310    */
311    function canExpressInstall() {
312        return !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac) && !(ua.wk && ua.wk < 312);
313    }
314   
315    /* Show the Adobe Express Install dialog
316        - Reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75
317    */
318    function showExpressInstall(att, par, replaceElemIdStr, callbackFn) {
319        isExpressInstallActive = true;
320        storedCallbackFn = callbackFn || null;
321        storedCallbackObj = {success:false, id:replaceElemIdStr};
322        var obj = getElementById(replaceElemIdStr);
323        if (obj) {
324            if (obj.nodeName == "OBJECT") { // static publishing
325                storedAltContent = abstractAltContent(obj);
326                storedAltContentId = null;
327            }
328            else { // dynamic publishing
329                storedAltContent = obj;
330                storedAltContentId = replaceElemIdStr;
331            }
332            att.id = EXPRESS_INSTALL_ID;
333            if (typeof att.width == UNDEF || (!(/%$/).test(att.width) && parseInt(att.width, 10) < 310)) {
334                att.width = "310";
335            }
336           
337            if (typeof att.height == UNDEF || (!(/%$/).test(att.height) && parseInt(att.height, 10) < 137)) {
338                att.height = "137";
339            }
340            doc.title = doc.title.slice(0, 47) + " - Flash Player Installation";
341            var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn",
342                fv = "MMredirectURL=" + win.location.toString().replace(/&/g,"%26") + "&MMplayerType=" + pt + "&MMdoctitle=" + doc.title;
343            if (typeof par.flashvars != UNDEF) {
344                par.flashvars += "&" + fv;
345            }
346            else {
347                par.flashvars = fv;
348            }
349            // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it,
350            // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
351            if (ua.ie && ua.win && obj.readyState != 4) {
352                var newObj = createElement("div");
353                replaceElemIdStr += "SWFObjectNew";
354                newObj.setAttribute("id", replaceElemIdStr);
355                obj.parentNode.insertBefore(newObj, obj); // insert placeholder div that will be replaced by the object element that loads expressinstall.swf
356                obj.style.display = "none";
357                (function(){
358                    if (obj.readyState == 4) {
359                        obj.parentNode.removeChild(obj);
360                    }
361                    else {
362                        setTimeout(arguments.callee, 10);
363                    }
364                })();
365            }
366            createSWF(att, par, replaceElemIdStr);
367        }
368    }
369   
370    /* Functions to abstract and display alternative content
371    */
372    function displayAltContent(obj) {
373        if (ua.ie && ua.win && obj.readyState != 4) {
374            // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it,
375            // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
376            var el = createElement("div");
377            obj.parentNode.insertBefore(el, obj); // insert placeholder div that will be replaced by the alternative content
378            el.parentNode.replaceChild(abstractAltContent(obj), el);
379            obj.style.display = "none";
380            (function(){
381                if (obj.readyState == 4) {
382                    obj.parentNode.removeChild(obj);
383                }
384                else {
385                    setTimeout(arguments.callee, 10);
386                }
387            })();
388        }
389        else {
390            obj.parentNode.replaceChild(abstractAltContent(obj), obj);
391        }
392    } 
393
394    function abstractAltContent(obj) {
395        var ac = createElement("div");
396        if (ua.win && ua.ie) {
397            ac.innerHTML = obj.innerHTML;
398        }
399        else {
400            var nestedObj = obj.getElementsByTagName(OBJECT)[0];
401            if (nestedObj) {
402                var c = nestedObj.childNodes;
403                if (c) {
404                    var cl = c.length;
405                    for (var i = 0; i < cl; i++) {
406                        if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) {
407                            ac.appendChild(c[i].cloneNode(true));
408                        }
409                    }
410                }
411            }
412        }
413        return ac;
414    }
415   
416    /* Cross-browser dynamic SWF creation
417    */
418    function createSWF(attObj, parObj, id) {
419        var r, el = getElementById(id);
420        if (ua.wk && ua.wk < 312) { return r; }
421        if (el) {
422            if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content
423                attObj.id = id;
424            }
425            if (ua.ie && ua.win) { // Internet Explorer + the HTML object element + W3C DOM methods do not combine: fall back to outerHTML
426                var att = "";
427                for (var i in attObj) {
428                    if (attObj[i] != Object.prototype[i]) { // filter out prototype additions from other potential libraries
429                        if (i.toLowerCase() == "data") {
430                            parObj.movie = attObj[i];
431                        }
432                        else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
433                            att += ' class="' + attObj[i] + '"';
434                        }
435                        else if (i.toLowerCase() != "classid") {
436                            att += ' ' + i + '="' + attObj[i] + '"';
437                        }
438                    }
439                }
440                var par = "";
441                for (var j in parObj) {
442                    if (parObj[j] != Object.prototype[j]) { // filter out prototype additions from other potential libraries
443                        par += '<param name="' + j + '" value="' + parObj[j] + '" />';
444                    }
445                }
446                el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + '>' + par + '</object>';
447                objIdArr[objIdArr.length] = attObj.id; // stored to fix object 'leaks' on unload (dynamic publishing only)
448                r = getElementById(attObj.id); 
449            }
450            else { // well-behaving browsers
451                var o = createElement(OBJECT);
452                o.setAttribute("type", FLASH_MIME_TYPE);
453                for (var m in attObj) {
454                    if (attObj[m] != Object.prototype[m]) { // filter out prototype additions from other potential libraries
455                        if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
456                            o.setAttribute("class", attObj[m]);
457                        }
458                        else if (m.toLowerCase() != "classid") { // filter out IE specific attribute
459                            o.setAttribute(m, attObj[m]);
460                        }
461                    }
462                }
463                for (var n in parObj) {
464                    if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") { // filter out prototype additions from other potential libraries and IE specific param element
465                        createObjParam(o, n, parObj[n]);
466                    }
467                }
468                el.parentNode.replaceChild(o, el);
469                r = o;
470            }
471        }
472        return r;
473    }
474   
475    function createObjParam(el, pName, pValue) {
476        var p = createElement("param");
477        p.setAttribute("name", pName); 
478        p.setAttribute("value", pValue);
479        el.appendChild(p);
480    }
481   
482    /* Cross-browser SWF removal
483        - Especially needed to safely and completely remove a SWF in Internet Explorer
484    */
485    function removeSWF(id) {
486        var obj = getElementById(id);
487        if (obj && obj.nodeName == "OBJECT") {
488            if (ua.ie && ua.win) {
489                obj.style.display = "none";
490                (function(){
491                    if (obj.readyState == 4) {
492                        removeObjectInIE(id);
493                    }
494                    else {
495                        setTimeout(arguments.callee, 10);
496                    }
497                })();
498            }
499            else {
500                obj.parentNode.removeChild(obj);
501            }
502        }
503    }
504   
505    function removeObjectInIE(id) {
506        var obj = getElementById(id);
507        if (obj) {
508            for (var i in obj) {
509                if (typeof obj[i] == "function") {
510                    obj[i] = null;
511                }
512            }
513            obj.parentNode.removeChild(obj);
514        }
515    }
516   
517    /* Functions to optimize JavaScript compression
518    */
519    function getElementById(id) {
520        var el = null;
521        try {
522            el = doc.getElementById(id);
523        }
524        catch (e) {}
525        return el;
526    }
527   
528    function createElement(el) {
529        return doc.createElement(el);
530    }
531   
532    /* Updated attachEvent function for Internet Explorer
533        - Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks
534    */ 
535    function addListener(target, eventType, fn) {
536        target.attachEvent(eventType, fn);
537        listenersArr[listenersArr.length] = [target, eventType, fn];
538    }
539   
540    /* Flash Player and SWF content version matching
541    */
542    function hasPlayerVersion(rv) {
543        var pv = ua.pv, v = rv.split(".");
544        v[0] = parseInt(v[0], 10);
545        v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0"
546        v[2] = parseInt(v[2], 10) || 0;
547        return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
548    }
549   
550    /* Cross-browser dynamic CSS creation
551        - Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php
552    */ 
553    function createCSS(sel, decl, media, newStyle) {
554        if (ua.ie && ua.mac) { return; }
555        var h = doc.getElementsByTagName("head")[0];
556        if (!h) { return; } // to also support badly authored HTML pages that lack a head element
557        var m = (media && typeof media == "string") ? media : "screen";
558        if (newStyle) {
559            dynamicStylesheet = null;
560            dynamicStylesheetMedia = null;
561        }
562        if (!dynamicStylesheet || dynamicStylesheetMedia != m) { 
563            // create dynamic stylesheet + get a global reference to it
564            var s = createElement("style");
565            s.setAttribute("type", "text/css");
566            s.setAttribute("media", m);
567            dynamicStylesheet = h.appendChild(s);
568            if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) {
569                dynamicStylesheet = doc.styleSheets[doc.styleSheets.length - 1];
570            }
571            dynamicStylesheetMedia = m;
572        }
573        // add style rule
574        if (ua.ie && ua.win) {
575            if (dynamicStylesheet && typeof dynamicStylesheet.addRule == OBJECT) {
576                dynamicStylesheet.addRule(sel, decl);
577            }
578        }
579        else {
580            if (dynamicStylesheet && typeof doc.createTextNode != UNDEF) {
581                dynamicStylesheet.appendChild(doc.createTextNode(sel + " {" + decl + "}"));
582            }
583        }
584    }
585   
586    function setVisibility(id, isVisible) {
587        if (!autoHideShow) { return; }
588        var v = isVisible ? "visible" : "hidden";
589        if (isDomLoaded && getElementById(id)) {
590            getElementById(id).style.visibility = v;
591        }
592        else {
593            createCSS("#" + id, "visibility:" + v);
594        }
595    }
596
597    /* Filter to avoid XSS attacks
598    */
599    function urlEncodeIfNecessary(s) {
600        var regex = /[\\\"<>\.;]/;
601        var hasBadChars = regex.exec(s) != null;
602        return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s;
603    }
604   
605    /* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only)
606    */
607    var cleanup = function() {
608        if (ua.ie && ua.win) {
609            window.attachEvent("onunload", function() {
610                // remove listeners to avoid memory leaks
611                var ll = listenersArr.length;
612                for (var i = 0; i < ll; i++) {
613                    listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]);
614                }
615                // cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect
616                var il = objIdArr.length;
617                for (var j = 0; j < il; j++) {
618                    removeSWF(objIdArr[j]);
619                }
620                // cleanup library's main closures to avoid memory leaks
621                for (var k in ua) {
622                    ua[k] = null;
623                }
624                ua = null;
625                for (var l in swfobject) {
626                    swfobject[l] = null;
627                }
628                swfobject = null;
629                window.detachEvent('onunload', arguments.callee);
630            });
631        }
632    }();
633   
634    return {
635        /* Public API
636            - Reference: http://code.google.com/p/swfobject/wiki/documentation
637        */ 
638        registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr, callbackFn) {
639            if (ua.w3 && objectIdStr && swfVersionStr) {
640                var regObj = {};
641                regObj.id = objectIdStr;
642                regObj.swfVersion = swfVersionStr;
643                regObj.expressInstall = xiSwfUrlStr;
644                regObj.callbackFn = callbackFn;
645                regObjArr[regObjArr.length] = regObj;
646                setVisibility(objectIdStr, false);
647            }
648            else if (callbackFn) {
649                callbackFn({success:false, id:objectIdStr});
650            }
651        },
652       
653        getObjectById: function(objectIdStr) {
654            if (ua.w3) {
655                return getObjectById(objectIdStr);
656            }
657        },
658       
659        embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) {
660            var callbackObj = {success:false, id:replaceElemIdStr};
661            if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) {
662                setVisibility(replaceElemIdStr, false);
663                addDomLoadEvent(function() {
664                    widthStr += ""; // auto-convert to string
665                    heightStr += "";
666                    var att = {};
667                    if (attObj && typeof attObj === OBJECT) {
668                        for (var i in attObj) { // copy object to avoid the use of references, because web authors often reuse attObj for multiple SWFs
669                            att[i] = attObj[i];
670                        }
671                    }
672                    att.data = swfUrlStr;
673                    att.width = widthStr;
674                    att.height = heightStr;
675                    var par = {}; 
676                    if (parObj && typeof parObj === OBJECT) {
677                        for (var j in parObj) { // copy object to avoid the use of references, because web authors often reuse parObj for multiple SWFs
678                            par[j] = parObj[j];
679                        }
680                    }
681                    if (flashvarsObj && typeof flashvarsObj === OBJECT) {
682                        for (var k in flashvarsObj) { // copy object to avoid the use of references, because web authors often reuse flashvarsObj for multiple SWFs
683                            if (typeof par.flashvars != UNDEF) {
684                                par.flashvars += "&" + k + "=" + flashvarsObj[k];
685                            }
686                            else {
687                                par.flashvars = k + "=" + flashvarsObj[k];
688                            }
689                        }
690                    }
691                    if (hasPlayerVersion(swfVersionStr)) { // create SWF
692                        var obj = createSWF(att, par, replaceElemIdStr);
693                        if (att.id == replaceElemIdStr) {
694                            setVisibility(replaceElemIdStr, true);
695                        }
696                        callbackObj.success = true;
697                        callbackObj.ref = obj;
698                    }
699                    else if (xiSwfUrlStr && canExpressInstall()) { // show Adobe Express Install
700                        att.data = xiSwfUrlStr;
701                        showExpressInstall(att, par, replaceElemIdStr, callbackFn);
702                        return;
703                    }
704                    else { // show alternative content
705                        setVisibility(replaceElemIdStr, true);
706                    }
707                    if (callbackFn) { callbackFn(callbackObj); }
708                });
709            }
710            else if (callbackFn) { callbackFn(callbackObj); }
711        },
712       
713        switchOffAutoHideShow: function() {
714            autoHideShow = false;
715        },
716       
717        ua: ua,
718       
719        getFlashPlayerVersion: function() {
720            return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] };
721        },
722       
723        hasFlashPlayerVersion: hasPlayerVersion,
724       
725        createSWF: function(attObj, parObj, replaceElemIdStr) {
726            if (ua.w3) {
727                return createSWF(attObj, parObj, replaceElemIdStr);
728            }
729            else {
730                return undefined;
731            }
732        },
733       
734        showExpressInstall: function(att, par, replaceElemIdStr, callbackFn) {
735            if (ua.w3 && canExpressInstall()) {
736                showExpressInstall(att, par, replaceElemIdStr, callbackFn);
737            }
738        },
739       
740        removeSWF: function(objElemIdStr) {
741            if (ua.w3) {
742                removeSWF(objElemIdStr);
743            }
744        },
745       
746        createCSS: function(selStr, declStr, mediaStr, newStyleBoolean) {
747            if (ua.w3) {
748                createCSS(selStr, declStr, mediaStr, newStyleBoolean);
749            }
750        },
751       
752        addDomLoadEvent: addDomLoadEvent,
753       
754        addLoadEvent: addLoadEvent,
755       
756        getQueryParamValue: function(param) {
757            var q = doc.location.search || doc.location.hash;
758            if (q) {
759                if (/\?/.test(q)) { q = q.split("?")[1]; } // strip question mark
760                if (param == null) {
761                    return urlEncodeIfNecessary(q);
762                }
763                var pairs = q.split("&");
764                for (var i = 0; i < pairs.length; i++) {
765                    if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
766                        return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=") + 1)));
767                    }
768                }
769            }
770            return "";
771        },
772       
773        // For internal usage only
774        expressInstallCallback: function() {
775            if (isExpressInstallActive) {
776                var obj = getElementById(EXPRESS_INSTALL_ID);
777                if (obj && storedAltContent) {
778                    obj.parentNode.replaceChild(storedAltContent, obj);
779                    if (storedAltContentId) {
780                        setVisibility(storedAltContentId, true);
781                        if (ua.ie && ua.win) { storedAltContent.style.display = "block"; }
782                    }
783                    if (storedCallbackFn) { storedCallbackFn(storedCallbackObj); }
784                }
785                isExpressInstallActive = false;
786            } 
787        }
788    };
789}();
790/**
791 * @class Ext.FlashComponent
792 * @extends Ext.BoxComponent
793 * @constructor
794 * @xtype flash
795 */
796Ext.FlashComponent = Ext.extend(Ext.BoxComponent, {
797    /**
798     * @cfg {String} flashVersion
799     * Indicates the version the flash content was published for. Defaults to <tt>'9.0.115'</tt>.
800     */
801    flashVersion : '9.0.115',
802
803    /**
804     * @cfg {String} backgroundColor
805     * The background color of the chart. Defaults to <tt>'#ffffff'</tt>.
806     */
807    backgroundColor: '#ffffff',
808
809    /**
810     * @cfg {String} wmode
811     * The wmode of the flash object. This can be used to control layering. Defaults to <tt>'opaque'</tt>.
812     */
813    wmode: 'opaque',
814
815    /**
816     * @cfg {Object} flashVars
817     * A set of key value pairs to be passed to the flash object as flash variables. Defaults to <tt>undefined</tt>.
818     */
819    flashVars: undefined,
820
821    /**
822     * @cfg {Object} flashParams
823     * A set of key value pairs to be passed to the flash object as parameters. Possible parameters can be found here:
824     * http://kb2.adobe.com/cps/127/tn_12701.html Defaults to <tt>undefined</tt>.
825     */
826    flashParams: undefined,
827
828    /**
829     * @cfg {String} url
830     * The URL of the chart to include. Defaults to <tt>undefined</tt>.
831     */
832    url: undefined,
833    swfId : undefined,
834    swfWidth: '100%',
835    swfHeight: '100%',
836
837    /**
838     * @cfg {Boolean} expressInstall
839     * True to prompt the user to install flash if not installed. Note that this uses
840     * Ext.FlashComponent.EXPRESS_INSTALL_URL, which should be set to the local resource. Defaults to <tt>false</tt>.
841     */
842    expressInstall: false,
843
844    initComponent : function(){
845        Ext.FlashComponent.superclass.initComponent.call(this);
846
847        this.addEvents(
848            /**
849             * @event initialize
850             *
851             * @param {Chart} this
852             */
853            'initialize'
854        );
855    },
856
857    onRender : function(){
858        Ext.FlashComponent.superclass.onRender.apply(this, arguments);
859
860        var params = Ext.apply({
861            allowScriptAccess: 'always',
862            bgcolor: this.backgroundColor,
863            wmode: this.wmode
864        }, this.flashParams), vars = Ext.apply({
865            allowedDomain: document.location.hostname,
866            YUISwfId: this.getId(),
867            YUIBridgeCallback: 'Ext.FlashEventProxy.onEvent'
868        }, this.flashVars);
869
870        new swfobject.embedSWF(this.url, this.id, this.swfWidth, this.swfHeight, this.flashVersion,
871            this.expressInstall ? Ext.FlashComponent.EXPRESS_INSTALL_URL : undefined, vars, params);
872
873        this.swf = Ext.getDom(this.id);
874        this.el = Ext.get(this.swf);
875    },
876
877    getSwfId : function(){
878        return this.swfId || (this.swfId = "extswf" + (++Ext.Component.AUTO_ID));
879    },
880
881    getId : function(){
882        return this.id || (this.id = "extflashcmp" + (++Ext.Component.AUTO_ID));
883    },
884
885    onFlashEvent : function(e){
886        switch(e.type){
887            case "swfReady":
888                this.initSwf();
889                return;
890            case "log":
891                return;
892        }
893        e.component = this;
894        this.fireEvent(e.type.toLowerCase().replace(/event$/, ''), e);
895    },
896
897    initSwf : function(){
898        this.onSwfReady(!!this.isInitialized);
899        this.isInitialized = true;
900        this.fireEvent('initialize', this);
901    },
902
903    beforeDestroy: function(){
904        if(this.rendered){
905            swfobject.removeSWF(this.swf.id);
906        }
907        Ext.FlashComponent.superclass.beforeDestroy.call(this);
908    },
909
910    onSwfReady : Ext.emptyFn
911});
912
913/**
914 * Sets the url for installing flash if it doesn't exist. This should be set to a local resource.
915 * @static
916 * @type String
917 */
918Ext.FlashComponent.EXPRESS_INSTALL_URL = 'http:/' + '/swfobject.googlecode.com/svn/trunk/swfobject/expressInstall.swf';
919
920Ext.reg('flash', Ext.FlashComponent);/**
921 * @class Ext.FlashProxy
922 * @singleton
923 */
924Ext.FlashEventProxy = {
925    onEvent : function(id, e){
926        var fp = Ext.getCmp(id);
927        if(fp){
928            fp.onFlashEvent(e);
929        }else{
930            arguments.callee.defer(10, this, [id, e]);
931        }
932    }
933};/**
934 * @class Ext.chart.Chart
935 * @extends Ext.FlashComponent
936 * The Ext.chart package provides the capability to visualize data with flash based charting.
937 * Each chart binds directly to an Ext.data.Store enabling automatic updates of the chart.
938 * To change the look and feel of a chart, see the {@link #chartStyle} and {@link #extraStyle} config options.
939 * @constructor
940 * @xtype chart
941 */
942
943 Ext.chart.Chart = Ext.extend(Ext.FlashComponent, {
944    refreshBuffer: 100,
945
946    /**
947     * @cfg {String} backgroundColor
948     * @hide
949     */
950
951    /**
952     * @cfg {Object} chartStyle
953     * Sets styles for this chart. This contains default styling, so modifying this property will <b>override</b>
954     * the built in styles of the chart. Use {@link #extraStyle} to add customizations to the default styling.
955     */
956    chartStyle: {
957        padding: 10,
958        animationEnabled: true,
959        font: {
960            name: 'Tahoma',
961            color: 0x444444,
962            size: 11
963        },
964        dataTip: {
965            padding: 5,
966            border: {
967                color: 0x99bbe8,
968                size:1
969            },
970            background: {
971                color: 0xDAE7F6,
972                alpha: .9
973            },
974            font: {
975                name: 'Tahoma',
976                color: 0x15428B,
977                size: 10,
978                bold: true
979            }
980        }
981    },
982
983    /**
984     * @cfg {String} url
985     * The url to load the chart from. This defaults to Ext.chart.Chart.CHART_URL, which should
986     * be modified to point to the local charts resource.
987     */
988
989    /**
990     * @cfg {Object} extraStyle
991     * Contains extra styles that will be added or overwritten to the default chartStyle. Defaults to <tt>null</tt>.
992     * For a detailed list of the options available, visit the YUI Charts site
993     * at <a href="http://developer.yahoo.com/yui/charts/#basicstyles">http://developer.yahoo.com/yui/charts/#basicstyles</a><br/>
994     * Some of the options availabe:<br />
995     * <ul style="padding:5px;padding-left:16px;list-style-type:inherit;">
996     * <li><b>padding</b> - The space around the edge of the chart's contents. Padding does not increase the size of the chart.</li>
997     * <li><b>animationEnabled</b> - A Boolean value that specifies whether marker animations are enabled or not. Enabled by default.</li>
998     * <li><b>font</b> - An Object defining the font style to be used in the chart. Defaults to <tt>{ name: 'Tahoma', color: 0x444444, size: 11 }</tt><br/>
999     *  <ul style="padding:5px;padding-left:26px;list-style-type:circle;">
1000     *      <li><b>name</b> - font name</li>
1001     *      <li><b>color</b> - font color (hex code, ie: "#ff0000", "ff0000" or 0xff0000)</li>
1002     *      <li><b>size</b> - font size in points (numeric portion only, ie: 11)</li>
1003     *      <li><b>bold</b> - boolean</li>
1004     *      <li><b>italic</b> - boolean</li>
1005     *      <li><b>underline</b> - boolean</li>
1006     *  </ul>
1007     * </li>
1008     * <li><b>border</b> - An object defining the border style around the chart. The chart itself will decrease in dimensions to accomodate the border.<br/>
1009     *  <ul style="padding:5px;padding-left:26px;list-style-type:circle;">
1010     *      <li><b>color</b> - border color (hex code, ie: "#ff0000", "ff0000" or 0xff0000)</li>
1011     *      <li><b>size</b> - border size in pixels (numeric portion only, ie: 1)</li>
1012     *  </ul>
1013     * </li>
1014     * <li><b>background</b> - An object defining the background style of the chart.<br/>
1015     *  <ul style="padding:5px;padding-left:26px;list-style-type:circle;">
1016     *      <li><b>color</b> - border color (hex code, ie: "#ff0000", "ff0000" or 0xff0000)</li>
1017     *      <li><b>image</b> - an image URL. May be relative to the current document or absolute.</li>
1018     *  </ul>
1019     * </li>
1020     * <li><b>legend</b> - An object defining the legend style<br/>
1021     *  <ul style="padding:5px;padding-left:26px;list-style-type:circle;">
1022     *      <li><b>display</b> - location of the legend. Possible values are "none", "left", "right", "top", and "bottom".</li>
1023     *      <li><b>spacing</b> - an image URL. May be relative to the current document or absolute.</li>
1024     *      <li><b>padding, border, background, font</b> - same options as described above.</li>
1025     *  </ul></li>
1026     * <li><b>dataTip</b> - An object defining the style of the data tip (tooltip).<br/>
1027     *  <ul style="padding:5px;padding-left:26px;list-style-type:circle;">
1028     *      <li><b>padding, border, background, font</b> - same options as described above.</li>
1029     *  </ul></li>
1030     * <li><b>xAxis and yAxis</b> - An object defining the style of the style of either axis.<br/>
1031     *  <ul style="padding:5px;padding-left:26px;list-style-type:circle;">
1032     *      <li><b>color</b> - same option as described above.</li>
1033     *      <li><b>size</b> - same option as described above.</li>
1034     *      <li><b>showLabels</b> - boolean</li>
1035     *      <li><b>labelRotation</b> - a value in degrees from -90 through 90. Default is zero.</li>
1036     *  </ul></li>
1037     * <li><b>majorGridLines and minorGridLines</b> - An object defining the style of the style of the grid lines.<br/>
1038     *  <ul style="padding:5px;padding-left:26px;list-style-type:circle;">
1039     *      <li><b>color, size</b> - same options as described above.</li>
1040     *  </ul></li></li>
1041     * <li><b>zeroGridLine</b> - An object defining the style of the style of the zero grid line.<br/>
1042     *  <ul style="padding:5px;padding-left:26px;list-style-type:circle;">
1043     *      <li><b>color, size</b> - same options as described above.</li>
1044     *  </ul></li></li>
1045     * <li><b>majorTicks and minorTicks</b> - An object defining the style of the style of ticks in the chart.<br/>
1046     *  <ul style="padding:5px;padding-left:26px;list-style-type:circle;">
1047     *      <li><b>color, size</b> - same options as described above.</li>
1048     *      <li><b>length</b> - the length of each tick in pixels extending from the axis.</li>
1049     *      <li><b>display</b> - how the ticks are drawn. Possible values are "none", "inside", "outside", and "cross".</li>
1050     *  </ul></li></li>
1051     * </ul>
1052     */
1053    extraStyle: null,
1054
1055    /**
1056     * @cfg {Object} seriesStyles
1057     * Contains styles to apply to the series after a refresh. Defaults to <tt>null</tt>.
1058     */
1059    seriesStyles: null,
1060
1061    /**
1062     * @cfg {Boolean} disableCaching
1063     * True to add a "cache buster" to the end of the chart url. Defaults to true for Opera and IE.
1064     */
1065    disableCaching: Ext.isIE || Ext.isOpera,
1066    disableCacheParam: '_dc',
1067
1068    initComponent : function(){
1069        Ext.chart.Chart.superclass.initComponent.call(this);
1070        if(!this.url){
1071            this.url = Ext.chart.Chart.CHART_URL;
1072        }
1073        if(this.disableCaching){
1074            this.url = Ext.urlAppend(this.url, String.format('{0}={1}', this.disableCacheParam, new Date().getTime()));
1075        }
1076        this.addEvents(
1077            'itemmouseover',
1078            'itemmouseout',
1079            'itemclick',
1080            'itemdoubleclick',
1081            'itemdragstart',
1082            'itemdrag',
1083            'itemdragend',
1084            /**
1085             * @event beforerefresh
1086             * Fires before a refresh to the chart data is called.  If the beforerefresh handler returns
1087             * <tt>false</tt> the {@link #refresh} action will be cancelled.
1088             * @param {Chart} this
1089             */
1090            'beforerefresh',
1091            /**
1092             * @event refresh
1093             * Fires after the chart data has been refreshed.
1094             * @param {Chart} this
1095             */
1096            'refresh'
1097        );
1098        this.store = Ext.StoreMgr.lookup(this.store);
1099    },
1100
1101    /**
1102     * Sets a single style value on the Chart instance.
1103     *
1104     * @param name {String} Name of the Chart style value to change.
1105     * @param value {Object} New value to pass to the Chart style.
1106     */
1107     setStyle: function(name, value){
1108         this.swf.setStyle(name, Ext.encode(value));
1109     },
1110
1111    /**
1112     * Resets all styles on the Chart instance.
1113     *
1114     * @param styles {Object} Initializer for all Chart styles.
1115     */
1116    setStyles: function(styles){
1117        this.swf.setStyles(Ext.encode(styles));
1118    },
1119
1120    /**
1121     * Sets the styles on all series in the Chart.
1122     *
1123     * @param styles {Array} Initializer for all Chart series styles.
1124     */
1125    setSeriesStyles: function(styles){
1126        this.seriesStyles = styles;
1127        var s = [];
1128        Ext.each(styles, function(style){
1129            s.push(Ext.encode(style));
1130        });
1131        this.swf.setSeriesStyles(s);
1132    },
1133
1134    setCategoryNames : function(names){
1135        this.swf.setCategoryNames(names);
1136    },
1137
1138    setLegendRenderer : function(fn, scope){
1139        var chart = this;
1140        scope = scope || chart;
1141        chart.removeFnProxy(chart.legendFnName);
1142        chart.legendFnName = chart.createFnProxy(function(name){
1143            return fn.call(scope, name);
1144        });
1145        chart.swf.setLegendLabelFunction(chart.legendFnName);
1146    },
1147
1148    setTipRenderer : function(fn, scope){
1149        var chart = this;
1150        scope = scope || chart;
1151        chart.removeFnProxy(chart.tipFnName);
1152        chart.tipFnName = chart.createFnProxy(function(item, index, series){
1153            var record = chart.store.getAt(index);
1154            return fn.call(scope, chart, record, index, series);
1155        });
1156        chart.swf.setDataTipFunction(chart.tipFnName);
1157    },
1158
1159    setSeries : function(series){
1160        this.series = series;
1161        this.refresh();
1162    },
1163
1164    /**
1165     * Changes the data store bound to this chart and refreshes it.
1166     * @param {Store} store The store to bind to this chart
1167     */
1168    bindStore : function(store, initial){
1169        if(!initial && this.store){
1170            if(store !== this.store && this.store.autoDestroy){
1171                this.store.destroy();
1172            }else{
1173                this.store.un("datachanged", this.refresh, this);
1174                this.store.un("add", this.delayRefresh, this);
1175                this.store.un("remove", this.delayRefresh, this);
1176                this.store.un("update", this.delayRefresh, this);
1177                this.store.un("clear", this.refresh, this);
1178            }
1179        }
1180        if(store){
1181            store = Ext.StoreMgr.lookup(store);
1182            store.on({
1183                scope: this,
1184                datachanged: this.refresh,
1185                add: this.delayRefresh,
1186                remove: this.delayRefresh,
1187                update: this.delayRefresh,
1188                clear: this.refresh
1189            });
1190        }
1191        this.store = store;
1192        if(store && !initial){
1193            this.refresh();
1194        }
1195    },
1196
1197    onSwfReady : function(isReset){
1198        Ext.chart.Chart.superclass.onSwfReady.call(this, isReset);
1199        var ref;
1200        this.swf.setType(this.type);
1201
1202        if(this.chartStyle){
1203            this.setStyles(Ext.apply({}, this.extraStyle, this.chartStyle));
1204        }
1205
1206        if(this.categoryNames){
1207            this.setCategoryNames(this.categoryNames);
1208        }
1209
1210        if(this.tipRenderer){
1211            ref = this.getFunctionRef(this.tipRenderer);
1212            this.setTipRenderer(ref.fn, ref.scope);
1213        }
1214        if(this.legendRenderer){
1215            ref = this.getFunctionRef(this.legendRenderer);
1216            this.setLegendRenderer(ref.fn, ref.scope);
1217        }
1218        if(!isReset){
1219            this.bindStore(this.store, true);
1220        }
1221        this.refresh.defer(10, this);
1222    },
1223
1224    delayRefresh : function(){
1225        if(!this.refreshTask){
1226            this.refreshTask = new Ext.util.DelayedTask(this.refresh, this);
1227        }
1228        this.refreshTask.delay(this.refreshBuffer);
1229    },
1230
1231    refresh : function(){
1232        if(this.fireEvent('beforerefresh', this) !== false){
1233            var styleChanged = false;
1234            // convert the store data into something YUI charts can understand
1235            var data = [], rs = this.store.data.items;
1236            for(var j = 0, len = rs.length; j < len; j++){
1237                data[j] = rs[j].data;
1238            }
1239            //make a copy of the series definitions so that we aren't
1240            //editing them directly.
1241            var dataProvider = [];
1242            var seriesCount = 0;
1243            var currentSeries = null;
1244            var i = 0;
1245            if(this.series){
1246                seriesCount = this.series.length;
1247                for(i = 0; i < seriesCount; i++){
1248                    currentSeries = this.series[i];
1249                    var clonedSeries = {};
1250                    for(var prop in currentSeries){
1251                        if(prop == "style" && currentSeries.style !== null){
1252                            clonedSeries.style = Ext.encode(currentSeries.style);
1253                            styleChanged = true;
1254                            //we don't want to modify the styles again next time
1255                            //so null out the style property.
1256                            // this causes issues
1257                            // currentSeries.style = null;
1258                        } else{
1259                            clonedSeries[prop] = currentSeries[prop];
1260                        }
1261                    }
1262                    dataProvider.push(clonedSeries);
1263                }
1264            }
1265
1266            if(seriesCount > 0){
1267                for(i = 0; i < seriesCount; i++){
1268                    currentSeries = dataProvider[i];
1269                    if(!currentSeries.type){
1270                        currentSeries.type = this.type;
1271                    }
1272                    currentSeries.dataProvider = data;
1273                }
1274            } else{
1275                dataProvider.push({type: this.type, dataProvider: data});
1276            }
1277            this.swf.setDataProvider(dataProvider);
1278            if(this.seriesStyles){
1279                this.setSeriesStyles(this.seriesStyles);
1280            }
1281            this.fireEvent('refresh', this);
1282        }
1283    },
1284
1285    // private
1286    createFnProxy : function(fn){
1287        var fnName = 'extFnProxy' + (++Ext.chart.Chart.PROXY_FN_ID);
1288        Ext.chart.Chart.proxyFunction[fnName] = fn;
1289        return 'Ext.chart.Chart.proxyFunction.' + fnName;
1290    },
1291
1292    // private
1293    removeFnProxy : function(fn){
1294        if(!Ext.isEmpty(fn)){
1295            fn = fn.replace('Ext.chart.Chart.proxyFunction.', '');
1296            delete Ext.chart.Chart.proxyFunction[fn];
1297        }
1298    },
1299
1300    // private
1301    getFunctionRef : function(val){
1302        if(Ext.isFunction(val)){
1303            return {
1304                fn: val,
1305                scope: this
1306            };
1307        }else{
1308            return {
1309                fn: val.fn,
1310                scope: val.scope || this
1311            };
1312        }
1313    },
1314
1315    // private
1316    onDestroy: function(){
1317        if (this.refreshTask && this.refreshTask.cancel){
1318            this.refreshTask.cancel();
1319        }
1320        Ext.chart.Chart.superclass.onDestroy.call(this);
1321        this.bindStore(null);
1322        this.removeFnProxy(this.tipFnName);
1323        this.removeFnProxy(this.legendFnName);
1324    }
1325});
1326Ext.reg('chart', Ext.chart.Chart);
1327Ext.chart.Chart.PROXY_FN_ID = 0;
1328Ext.chart.Chart.proxyFunction = {};
1329
1330/**
1331 * Sets the url to load the chart from. This should be set to a local resource.
1332 * @static
1333 * @type String
1334 */
1335Ext.chart.Chart.CHART_URL = 'http:/' + '/yui.yahooapis.com/2.8.2/build/charts/assets/charts.swf';
1336
1337/**
1338 * @class Ext.chart.PieChart
1339 * @extends Ext.chart.Chart
1340 * @constructor
1341 * @xtype piechart
1342 */
1343Ext.chart.PieChart = Ext.extend(Ext.chart.Chart, {
1344    type: 'pie',
1345
1346    onSwfReady : function(isReset){
1347        Ext.chart.PieChart.superclass.onSwfReady.call(this, isReset);
1348
1349        this.setDataField(this.dataField);
1350        this.setCategoryField(this.categoryField);
1351    },
1352
1353    setDataField : function(field){
1354        this.dataField = field;
1355        this.swf.setDataField(field);
1356    },
1357
1358    setCategoryField : function(field){
1359        this.categoryField = field;
1360        this.swf.setCategoryField(field);
1361    }
1362});
1363Ext.reg('piechart', Ext.chart.PieChart);
1364
1365/**
1366 * @class Ext.chart.CartesianChart
1367 * @extends Ext.chart.Chart
1368 * @constructor
1369 * @xtype cartesianchart
1370 */
1371Ext.chart.CartesianChart = Ext.extend(Ext.chart.Chart, {
1372    onSwfReady : function(isReset){
1373        Ext.chart.CartesianChart.superclass.onSwfReady.call(this, isReset);
1374        this.labelFn = [];
1375        if(this.xField){
1376            this.setXField(this.xField);
1377        }
1378        if(this.yField){
1379            this.setYField(this.yField);
1380        }
1381        if(this.xAxis){
1382            this.setXAxis(this.xAxis);
1383        }
1384        if(this.xAxes){
1385            this.setXAxes(this.xAxes);
1386        }
1387        if(this.yAxis){
1388            this.setYAxis(this.yAxis);
1389        }
1390        if(this.yAxes){
1391            this.setYAxes(this.yAxes);
1392        }
1393        if(Ext.isDefined(this.constrainViewport)){
1394            this.swf.setConstrainViewport(this.constrainViewport);
1395        }
1396    },
1397
1398    setXField : function(value){
1399        this.xField = value;
1400        this.swf.setHorizontalField(value);
1401    },
1402
1403    setYField : function(value){
1404        this.yField = value;
1405        this.swf.setVerticalField(value);
1406    },
1407
1408    setXAxis : function(value){
1409        this.xAxis = this.createAxis('xAxis', value);
1410        this.swf.setHorizontalAxis(this.xAxis);
1411    },
1412
1413    setXAxes : function(value){
1414        var axis;
1415        for(var i = 0; i < value.length; i++) {
1416            axis = this.createAxis('xAxis' + i, value[i]);
1417            this.swf.setHorizontalAxis(axis);
1418        }
1419    },
1420
1421    setYAxis : function(value){
1422        this.yAxis = this.createAxis('yAxis', value);
1423        this.swf.setVerticalAxis(this.yAxis);
1424    },
1425
1426    setYAxes : function(value){
1427        var axis;
1428        for(var i = 0; i < value.length; i++) {
1429            axis = this.createAxis('yAxis' + i, value[i]);
1430            this.swf.setVerticalAxis(axis);
1431        }
1432    },
1433
1434    createAxis : function(axis, value){
1435        var o = Ext.apply({}, value),
1436            ref,
1437            old;
1438
1439        if(this[axis]){
1440            old = this[axis].labelFunction;
1441            this.removeFnProxy(old);
1442            this.labelFn.remove(old);
1443        }
1444        if(o.labelRenderer){
1445            ref = this.getFunctionRef(o.labelRenderer);
1446            o.labelFunction = this.createFnProxy(function(v){
1447                return ref.fn.call(ref.scope, v);
1448            });
1449            delete o.labelRenderer;
1450            this.labelFn.push(o.labelFunction);
1451        }
1452        if(axis.indexOf('xAxis') > -1 && o.position == 'left'){
1453            o.position = 'bottom';
1454        }
1455        return o;
1456    },
1457
1458    onDestroy : function(){
1459        Ext.chart.CartesianChart.superclass.onDestroy.call(this);
1460        Ext.each(this.labelFn, function(fn){
1461            this.removeFnProxy(fn);
1462        }, this);
1463    }
1464});
1465Ext.reg('cartesianchart', Ext.chart.CartesianChart);
1466
1467/**
1468 * @class Ext.chart.LineChart
1469 * @extends Ext.chart.CartesianChart
1470 * @constructor
1471 * @xtype linechart
1472 */
1473Ext.chart.LineChart = Ext.extend(Ext.chart.CartesianChart, {
1474    type: 'line'
1475});
1476Ext.reg('linechart', Ext.chart.LineChart);
1477
1478/**
1479 * @class Ext.chart.ColumnChart
1480 * @extends Ext.chart.CartesianChart
1481 * @constructor
1482 * @xtype columnchart
1483 */
1484Ext.chart.ColumnChart = Ext.extend(Ext.chart.CartesianChart, {
1485    type: 'column'
1486});
1487Ext.reg('columnchart', Ext.chart.ColumnChart);
1488
1489/**
1490 * @class Ext.chart.StackedColumnChart
1491 * @extends Ext.chart.CartesianChart
1492 * @constructor
1493 * @xtype stackedcolumnchart
1494 */
1495Ext.chart.StackedColumnChart = Ext.extend(Ext.chart.CartesianChart, {
1496    type: 'stackcolumn'
1497});
1498Ext.reg('stackedcolumnchart', Ext.chart.StackedColumnChart);
1499
1500/**
1501 * @class Ext.chart.BarChart
1502 * @extends Ext.chart.CartesianChart
1503 * @constructor
1504 * @xtype barchart
1505 */
1506Ext.chart.BarChart = Ext.extend(Ext.chart.CartesianChart, {
1507    type: 'bar'
1508});
1509Ext.reg('barchart', Ext.chart.BarChart);
1510
1511/**
1512 * @class Ext.chart.StackedBarChart
1513 * @extends Ext.chart.CartesianChart
1514 * @constructor
1515 * @xtype stackedbarchart
1516 */
1517Ext.chart.StackedBarChart = Ext.extend(Ext.chart.CartesianChart, {
1518    type: 'stackbar'
1519});
1520Ext.reg('stackedbarchart', Ext.chart.StackedBarChart);
1521
1522
1523
1524/**
1525 * @class Ext.chart.Axis
1526 * Defines a CartesianChart's vertical or horizontal axis.
1527 * @constructor
1528 */
1529Ext.chart.Axis = function(config){
1530    Ext.apply(this, config);
1531};
1532
1533Ext.chart.Axis.prototype =
1534{
1535    /**
1536     * The type of axis.
1537     *
1538     * @property type
1539     * @type String
1540     */
1541    type: null,
1542
1543    /**
1544     * The direction in which the axis is drawn. May be "horizontal" or "vertical".
1545     *
1546     * @property orientation
1547     * @type String
1548     */
1549    orientation: "horizontal",
1550
1551    /**
1552     * If true, the items on the axis will be drawn in opposite direction.
1553     *
1554     * @property reverse
1555     * @type Boolean
1556     */
1557    reverse: false,
1558
1559    /**
1560     * A string reference to the globally-accessible function that may be called to
1561     * determine each of the label values for this axis.
1562     *
1563     * @property labelFunction
1564     * @type String
1565     */
1566    labelFunction: null,
1567
1568    /**
1569     * If true, labels that overlap previously drawn labels on the axis will be hidden.
1570     *
1571     * @property hideOverlappingLabels
1572     * @type Boolean
1573     */
1574    hideOverlappingLabels: true,
1575
1576    /**
1577     * The space, in pixels, between labels on an axis.
1578     *
1579     * @property labelSpacing
1580     * @type Number
1581     */
1582    labelSpacing: 2
1583};
1584
1585/**
1586 * @class Ext.chart.NumericAxis
1587 * @extends Ext.chart.Axis
1588 * A type of axis whose units are measured in numeric values.
1589 * @constructor
1590 */
1591Ext.chart.NumericAxis = Ext.extend(Ext.chart.Axis, {
1592    type: "numeric",
1593
1594    /**
1595     * The minimum value drawn by the axis. If not set explicitly, the axis
1596     * minimum will be calculated automatically.
1597     *
1598     * @property minimum
1599     * @type Number
1600     */
1601    minimum: NaN,
1602
1603    /**
1604     * The maximum value drawn by the axis. If not set explicitly, the axis
1605     * maximum will be calculated automatically.
1606     *
1607     * @property maximum
1608     * @type Number
1609     */
1610    maximum: NaN,
1611
1612    /**
1613     * The spacing between major intervals on this axis.
1614     *
1615     * @property majorUnit
1616     * @type Number
1617     */
1618    majorUnit: NaN,
1619
1620    /**
1621     * The spacing between minor intervals on this axis.
1622     *
1623     * @property minorUnit
1624     * @type Number
1625     */
1626    minorUnit: NaN,
1627
1628    /**
1629     * If true, the labels, ticks, gridlines, and other objects will snap to the
1630     * nearest major or minor unit. If false, their position will be based on
1631     * the minimum value.
1632     *
1633     * @property snapToUnits
1634     * @type Boolean
1635     */
1636    snapToUnits: true,
1637
1638    /**
1639     * If true, and the bounds are calculated automatically, either the minimum
1640     * or maximum will be set to zero.
1641     *
1642     * @property alwaysShowZero
1643     * @type Boolean
1644     */
1645    alwaysShowZero: true,
1646
1647    /**
1648     * The scaling algorithm to use on this axis. May be "linear" or
1649     * "logarithmic".
1650     *
1651     * @property scale
1652     * @type String
1653     */
1654    scale: "linear",
1655
1656    /**
1657     * Indicates whether to round the major unit.
1658     *
1659     * @property roundMajorUnit
1660     * @type Boolean
1661     */
1662    roundMajorUnit: true,
1663
1664    /**
1665     * Indicates whether to factor in the size of the labels when calculating a
1666     * major unit.
1667     *
1668     * @property calculateByLabelSize
1669     * @type Boolean
1670     */
1671    calculateByLabelSize: true,
1672
1673    /**
1674     * Indicates the position of the axis relative to the chart
1675     *
1676     * @property position
1677     * @type String
1678     */
1679    position: 'left',
1680
1681    /**
1682     * Indicates whether to extend maximum beyond data's maximum to the nearest
1683     * majorUnit.
1684     *
1685     * @property adjustMaximumByMajorUnit
1686     * @type Boolean
1687     */
1688    adjustMaximumByMajorUnit: true,
1689
1690    /**
1691     * Indicates whether to extend the minimum beyond data's minimum to the
1692     * nearest majorUnit.
1693     *
1694     * @property adjustMinimumByMajorUnit
1695     * @type Boolean
1696     */
1697    adjustMinimumByMajorUnit: true
1698
1699});
1700
1701/**
1702 * @class Ext.chart.TimeAxis
1703 * @extends Ext.chart.Axis
1704 * A type of axis whose units are measured in time-based values.
1705 * @constructor
1706 */
1707Ext.chart.TimeAxis = Ext.extend(Ext.chart.Axis, {
1708    type: "time",
1709
1710    /**
1711     * The minimum value drawn by the axis. If not set explicitly, the axis
1712     * minimum will be calculated automatically.
1713     *
1714     * @property minimum
1715     * @type Date
1716     */
1717    minimum: null,
1718
1719    /**
1720     * The maximum value drawn by the axis. If not set explicitly, the axis
1721     * maximum will be calculated automatically.
1722     *
1723     * @property maximum
1724     * @type Number
1725     */
1726    maximum: null,
1727
1728    /**
1729     * The spacing between major intervals on this axis.
1730     *
1731     * @property majorUnit
1732     * @type Number
1733     */
1734    majorUnit: NaN,
1735
1736    /**
1737     * The time unit used by the majorUnit.
1738     *
1739     * @property majorTimeUnit
1740     * @type String
1741     */
1742    majorTimeUnit: null,
1743
1744    /**
1745     * The spacing between minor intervals on this axis.
1746     *
1747     * @property majorUnit
1748     * @type Number
1749     */
1750    minorUnit: NaN,
1751
1752    /**
1753     * The time unit used by the minorUnit.
1754     *
1755     * @property majorTimeUnit
1756     * @type String
1757     */
1758    minorTimeUnit: null,
1759
1760    /**
1761     * If true, the labels, ticks, gridlines, and other objects will snap to the
1762     * nearest major or minor unit. If false, their position will be based on
1763     * the minimum value.
1764     *
1765     * @property snapToUnits
1766     * @type Boolean
1767     */
1768    snapToUnits: true,
1769
1770    /**
1771     * Series that are stackable will only stack when this value is set to true.
1772     *
1773     * @property stackingEnabled
1774     * @type Boolean
1775     */
1776    stackingEnabled: false,
1777
1778    /**
1779     * Indicates whether to factor in the size of the labels when calculating a
1780     * major unit.
1781     *
1782     * @property calculateByLabelSize
1783     * @type Boolean
1784     */
1785    calculateByLabelSize: true
1786
1787});
1788
1789/**
1790 * @class Ext.chart.CategoryAxis
1791 * @extends Ext.chart.Axis
1792 * A type of axis that displays items in categories.
1793 * @constructor
1794 */
1795Ext.chart.CategoryAxis = Ext.extend(Ext.chart.Axis, {
1796    type: "category",
1797
1798    /**
1799     * A list of category names to display along this axis.
1800     *
1801     * @property categoryNames
1802     * @type Array
1803     */
1804    categoryNames: null,
1805
1806    /**
1807     * Indicates whether or not to calculate the number of categories (ticks and
1808     * labels) when there is not enough room to display all labels on the axis.
1809     * If set to true, the axis will determine the number of categories to plot.
1810     * If not, all categories will be plotted.
1811     *
1812     * @property calculateCategoryCount
1813     * @type Boolean
1814     */
1815    calculateCategoryCount: false
1816
1817});
1818
1819/**
1820 * @class Ext.chart.Series
1821 * Series class for the charts widget.
1822 * @constructor
1823 */
1824Ext.chart.Series = function(config) { Ext.apply(this, config); };
1825
1826Ext.chart.Series.prototype =
1827{
1828    /**
1829     * The type of series.
1830     *
1831     * @property type
1832     * @type String
1833     */
1834    type: null,
1835
1836    /**
1837     * The human-readable name of the series.
1838     *
1839     * @property displayName
1840     * @type String
1841     */
1842    displayName: null
1843};
1844
1845/**
1846 * @class Ext.chart.CartesianSeries
1847 * @extends Ext.chart.Series
1848 * CartesianSeries class for the charts widget.
1849 * @constructor
1850 */
1851Ext.chart.CartesianSeries = Ext.extend(Ext.chart.Series, {
1852    /**
1853     * The field used to access the x-axis value from the items from the data
1854     * source.
1855     *
1856     * @property xField
1857     * @type String
1858     */
1859    xField: null,
1860
1861    /**
1862     * The field used to access the y-axis value from the items from the data
1863     * source.
1864     *
1865     * @property yField
1866     * @type String
1867     */
1868    yField: null,
1869
1870    /**
1871     * False to not show this series in the legend. Defaults to <tt>true</tt>.
1872     *
1873     * @property showInLegend
1874     * @type Boolean
1875     */
1876    showInLegend: true,
1877
1878    /**
1879     * Indicates which axis the series will bind to
1880     *
1881     * @property axis
1882     * @type String
1883     */
1884    axis: 'primary'
1885});
1886
1887/**
1888 * @class Ext.chart.ColumnSeries
1889 * @extends Ext.chart.CartesianSeries
1890 * ColumnSeries class for the charts widget.
1891 * @constructor
1892 */
1893Ext.chart.ColumnSeries = Ext.extend(Ext.chart.CartesianSeries, {
1894    type: "column"
1895});
1896
1897/**
1898 * @class Ext.chart.LineSeries
1899 * @extends Ext.chart.CartesianSeries
1900 * LineSeries class for the charts widget.
1901 * @constructor
1902 */
1903Ext.chart.LineSeries = Ext.extend(Ext.chart.CartesianSeries, {
1904    type: "line"
1905});
1906
1907/**
1908 * @class Ext.chart.BarSeries
1909 * @extends Ext.chart.CartesianSeries
1910 * BarSeries class for the charts widget.
1911 * @constructor
1912 */
1913Ext.chart.BarSeries = Ext.extend(Ext.chart.CartesianSeries, {
1914    type: "bar"
1915});
1916
1917
1918/**
1919 * @class Ext.chart.PieSeries
1920 * @extends Ext.chart.Series
1921 * PieSeries class for the charts widget.
1922 * @constructor
1923 */
1924Ext.chart.PieSeries = Ext.extend(Ext.chart.Series, {
1925    type: "pie",
1926    dataField: null,
1927    categoryField: null
1928});
Note: See TracBrowser for help on using the repository browser.