2 Copyright (c) 2008, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.net/yui/license.txt
7 /*extern ActiveXObject, __flash_unloadHandler, __flash_savedUnloadHandler */
9 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
11 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
12 * http://www.opensource.org/licenses/mit-license.php
14 var deconcept
= deconcept
|| {};
16 if(typeof deconcept
.util
== "undefined" || !deconcept
.util
)
21 if(typeof deconcept
.SWFObjectUtil
== "undefined" || !deconcept
.SWFObjectUtil
)
23 deconcept
.SWFObjectUtil
= {};
26 deconcept
.SWFObject = function(swf
, id
, w
, h
, ver
, c
, quality
, xiRedirectUrl
, redirectUrl
, detectKey
)
28 if(!document
.getElementById
) { return; }
29 this.DETECT_KEY
= detectKey
? detectKey
: 'detectflash';
30 this.skipDetect
= deconcept
.util
.getRequestParameter(this.DETECT_KEY
);
34 if(swf
) { this.setAttribute('swf', swf
); }
35 if(id
) { this.setAttribute('id', id
); }
36 if(w
) { this.setAttribute('width', w
); }
37 if(h
) { this.setAttribute('height', h
); }
38 if(ver
) { this.setAttribute('version', new deconcept
.PlayerVersion(ver
.toString().split("."))); }
39 this.installedVer
= deconcept
.SWFObjectUtil
.getPlayerVersion();
40 if (!window
.opera
&& document
.all
&& this.installedVer
.major
> 7)
42 // only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
43 deconcept
.SWFObject
.doPrepUnload
= true;
47 this.addParam('bgcolor', c
);
49 var q
= quality
? quality
: 'high';
50 this.addParam('quality', q
);
51 this.setAttribute('useExpressInstall', false);
52 this.setAttribute('doExpressInstall', false);
53 var xir
= (xiRedirectUrl
) ? xiRedirectUrl
: window
.location
;
54 this.setAttribute('xiRedirectUrl', xir
);
55 this.setAttribute('redirectUrl', '');
58 this.setAttribute('redirectUrl', redirectUrl
);
62 deconcept
.SWFObject
.prototype =
64 useExpressInstall: function(path
)
66 this.xiSWFPath
= !path
? "expressinstall.swf" : path
;
67 this.setAttribute('useExpressInstall', true);
69 setAttribute: function(name
, value
){
70 this.attributes
[name
] = value
;
72 getAttribute: function(name
){
73 return this.attributes
[name
];
75 addParam: function(name
, value
){
76 this.params
[name
] = value
;
78 getParams: function(){
81 addVariable: function(name
, value
){
82 this.variables
[name
] = value
;
84 getVariable: function(name
){
85 return this.variables
[name
];
87 getVariables: function(){
88 return this.variables
;
90 getVariablePairs: function(){
91 var variablePairs
= [];
93 var variables
= this.getVariables();
94 for(key
in variables
){
95 variablePairs
[variablePairs
.length
] = key
+"="+ variables
[key
];
99 getSWFHTML: function() {
104 if (navigator
.plugins
&& navigator
.mimeTypes
&& navigator
.mimeTypes
.length
) { // netscape plugin architecture
105 if (this.getAttribute("doExpressInstall")) {
106 this.addVariable("MMplayerType", "PlugIn");
107 this.setAttribute('swf', this.xiSWFPath
);
109 swfNode
= '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'"';
110 swfNode
+= ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
111 params
= this.getParams();
112 for(key
in params
){ swfNode
+= [key
] +'="'+ params
[key
] +'" '; }
113 pairs
= this.getVariablePairs().join("&");
114 if (pairs
.length
> 0){ swfNode
+= 'flashvars="'+ pairs
+'"'; }
117 if (this.getAttribute("doExpressInstall")) {
118 this.addVariable("MMplayerType", "ActiveX");
119 this.setAttribute('swf', this.xiSWFPath
);
121 swfNode
= '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'">';
122 swfNode
+= '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
123 params
= this.getParams();
125 swfNode
+= '<param name="'+ key
+'" value="'+ params
[key
] +'" />';
127 pairs
= this.getVariablePairs().join("&");
128 if(pairs
.length
> 0) {swfNode
+= '<param name="flashvars" value="'+ pairs
+'" />';}
129 swfNode
+= "</object>";
133 write: function(elementId
)
135 if(this.getAttribute('useExpressInstall')) {
136 // check to see if we need to do an express install
137 var expressInstallReqVer
= new deconcept
.PlayerVersion([6,0,65]);
138 if (this.installedVer
.versionIsValid(expressInstallReqVer
) && !this.installedVer
.versionIsValid(this.getAttribute('version'))) {
139 this.setAttribute('doExpressInstall', true);
140 this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
141 document
.title
= document
.title
.slice(0, 47) + " - Flash Player Installation";
142 this.addVariable("MMdoctitle", document
.title
);
145 if(this.skipDetect
|| this.getAttribute('doExpressInstall') || this.installedVer
.versionIsValid(this.getAttribute('version')))
147 var n
= (typeof elementId
== 'string') ? document
.getElementById(elementId
) : elementId
;
148 n
.innerHTML
= this.getSWFHTML();
153 if(this.getAttribute('redirectUrl') !== "")
155 document
.location
.replace(this.getAttribute('redirectUrl'));
162 /* ---- detection functions ---- */
163 deconcept
.SWFObjectUtil
.getPlayerVersion = function()
166 var PlayerVersion
= new deconcept
.PlayerVersion([0,0,0]);
167 if(navigator
.plugins
&& navigator
.mimeTypes
.length
)
169 var x
= navigator
.plugins
["Shockwave Flash"];
170 if(x
&& x
.description
)
172 PlayerVersion
= new deconcept
.PlayerVersion(x
.description
.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
175 else if (navigator
.userAgent
&& navigator
.userAgent
.indexOf("Windows CE") >= 0)
183 axo
= new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter
);
184 // document.write("player v: "+ counter);
185 PlayerVersion
= new deconcept
.PlayerVersion([counter
,0,0]);
194 { // Win IE (non mobile)
195 // do minor version lookup in IE, but avoid fp6 crashing issues
196 // see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
199 axo
= new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
205 axo
= new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
206 PlayerVersion
= new deconcept
.PlayerVersion([6,0,21]);
207 axo
.AllowScriptAccess
= "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
211 if(PlayerVersion
.major
== 6)
213 return PlayerVersion
;
218 axo
= new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
225 PlayerVersion
= new deconcept
.PlayerVersion(axo
.GetVariable("$version").split(" ")[1].split(","));
228 return PlayerVersion
;
231 deconcept
.PlayerVersion = function(arrVersion
)
233 this.major
= arrVersion
[0] !== null ? parseInt(arrVersion
[0], 0) : 0;
234 this.minor
= arrVersion
[1] !== null ? parseInt(arrVersion
[1], 0) : 0;
235 this.rev
= arrVersion
[2] !== null ? parseInt(arrVersion
[2], 0) : 0;
238 deconcept
.PlayerVersion
.prototype.versionIsValid = function(fv
)
240 if(this.major
< fv
.major
)
244 if(this.major
> fv
.major
)
248 if(this.minor
< fv
.minor
)
252 if(this.minor
> fv
.minor
)
256 if(this.rev
< fv
.rev
)
263 /* ---- get value of query string param ---- */
266 getRequestParameter: function(param
)
268 var q
= document
.location
.search
|| document
.location
.hash
;
269 if(param
=== null) { return q
; }
272 var pairs
= q
.substring(1).split("&");
273 for(var i
=0; i
< pairs
.length
; i
++)
275 if (pairs
[i
].substring(0, pairs
[i
].indexOf("=")) == param
)
277 return pairs
[i
].substring((pairs
[i
].indexOf("=") + 1));
285 /* fix for video streaming bug */
286 deconcept
.SWFObjectUtil
.cleanupSWFs = function()
288 var objects
= document
.getElementsByTagName("OBJECT");
289 for(var i
= objects
.length
- 1; i
>= 0; i
--)
291 objects
[i
].style
.display
= 'none';
292 for(var x
in objects
[i
])
294 if(typeof objects
[i
][x
] == 'function')
296 objects
[i
][x
] = function(){};
302 // fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
303 if(deconcept
.SWFObject
.doPrepUnload
)
305 if(!deconcept
.unloadSet
)
307 deconcept
.SWFObjectUtil
.prepUnload = function()
309 __flash_unloadHandler = function(){};
310 __flash_savedUnloadHandler = function(){};
311 window
.attachEvent("onunload", deconcept
.SWFObjectUtil
.cleanupSWFs
);
313 window
.attachEvent("onbeforeunload", deconcept
.SWFObjectUtil
.prepUnload
);
314 deconcept
.unloadSet
= true;
318 /* add document.getElementById if needed (mobile IE < 5) */
319 if(!document
.getElementById
&& document
.all
)
321 document
.getElementById = function(id
) { return document
.all
[id
]; };
324 /* add some aliases for ease of use/backwards compatibility */
325 var getQueryParamValue = deconcept.util.getRequestParameter;
326 var FlashObject = deconcept.SWFObject; // for legacy support
327 var SWFObject = deconcept.SWFObject;
330 * Wraps Flash embedding functionality and allows communication with SWF through
333 * @namespace YAHOO.widget
334 * @class FlashAdapter
335 * @uses YAHOO.util.AttributeProvider
337 YAHOO
.widget
.FlashAdapter = function(swfURL
, containerID
, attributes
)
339 // set up the initial events and attributes stuff
340 this._queue
= this._queue
|| [];
341 this._events
= this._events
|| {};
342 this._configs
= this._configs
|| {};
343 attributes
= attributes
|| {};
345 //the Flash Player external interface code from Adobe doesn't play nicely
346 //with the default value, yui-gen, in IE
347 this._id
= attributes
.id
= attributes
.id
|| YAHOO
.util
.Dom
.generateId(null, "yuigen");
348 attributes
.version
= attributes
.version
|| "9.0.45";
349 attributes
.backgroundColor
= attributes
.backgroundColor
|| "#ffffff";
351 //we can't use the initial attributes right away
352 //so save them for once the SWF finishes loading
353 this._attributes
= attributes
;
355 this._swfURL
= swfURL
;
356 this._containerID
= containerID
;
358 //embed the SWF file in the page
359 this._embedSWF(this._swfURL
, this._containerID
, attributes
.id
, attributes
.version
,
360 attributes
.backgroundColor
, attributes
.expressInstall
, attributes
.wmode
);
363 * Fires when the SWF is initialized and communication is possible.
364 * @event contentReady
366 this.createEvent("contentReady");
369 YAHOO
.extend(YAHOO
.widget
.FlashAdapter
, YAHOO
.util
.AttributeProvider
,
372 * The URL of the SWF file.
380 * The ID of the containing DIV.
381 * @property _containerID
388 * A reference to the embedded SWF file.
395 * The id of this instance.
403 * The initializing attributes are stored here until the SWF is ready.
404 * @property _attributes
408 _attributes
: null, //the intializing attributes
411 * Public accessor to the unique name of the FlashAdapter instance.
414 * @return {String} Unique name of the FlashAdapter instance.
418 return "FlashAdapter " + this._id
;
422 * Nulls out the entire FlashAdapter instance and related objects and removes attached
423 * event listeners and clears out DOM elements inside the container. After calling
424 * this method, the instance reference should be expliclitly nulled by implementer,
425 * as in myChart = null. Use with caution!
431 //kill the Flash Player instance
434 var container
= YAHOO
.util
.Dom
.get(this._containerID
);
435 container
.removeChild(this._swf
);
438 var instanceName
= this._id
;
440 //null out properties
441 for(var prop
in this)
443 if(YAHOO
.lang
.hasOwnProperty(this, prop
))
452 * Embeds the SWF in the page and associates it with this instance.
457 _embedSWF: function(swfURL
, containerID
, swfID
, version
, backgroundColor
, expressInstall
, wmode
)
459 //standard SWFObject embed
460 var swfObj
= new deconcept
.SWFObject(swfURL
, swfID
, "100%", "100%", version
, backgroundColor
);
464 swfObj
.useExpressInstall(expressInstall
);
467 //make sure we can communicate with ExternalInterface
468 swfObj
.addParam("allowScriptAccess", "always");
472 swfObj
.addParam("wmode", wmode
);
475 //again, a useful ExternalInterface trick
476 swfObj
.addVariable("allowedDomain", document
.location
.hostname
);
478 //tell the SWF which HTML element it is in
479 swfObj
.addVariable("elementID", swfID
);
481 // set the name of the function to call when the swf has an event
482 swfObj
.addVariable("eventHandler", "YAHOO.widget.FlashAdapter.eventHandler");
484 var container
= YAHOO
.util
.Dom
.get(containerID
);
485 var result
= swfObj
.write(container
);
488 this._swf
= YAHOO
.util
.Dom
.get(swfID
);
489 //if successful, let's add an owner property to the SWF reference
490 //this will allow the event handler to communicate with a YAHOO.widget.FlashAdapter
491 this._swf
.owner
= this;
499 * Handles or re-dispatches events received from the SWF.
501 * @method _eventHandler
504 _eventHandler: function(event
)
506 var type
= event
.type
;
516 //be sure to return after your case or the event will automatically fire!
517 this.fireEvent(type
, event
);
521 * Called when the SWF has been initialized.
523 * @method _loadHandler
526 _loadHandler: function()
528 this._initAttributes(this._attributes
);
529 this.setAttributes(this._attributes
, true);
530 this._attributes
= null;
532 this.fireEvent("contentReady");
536 * Initializes the attributes.
538 * @method _initAttributes
541 _initAttributes: function(attributes
)
543 //should be overridden if other attributes need to be set up
547 * @description Sets the window mode of the Flash Player control. May be
548 * "window", "opaque", or "transparent". Only available in the constructor
549 * because it may not be set after Flash Player has been embedded in the page.
554 * @attribute expressInstall
555 * @description URL pointing to a SWF file that handles Flash Player's express
556 * install feature. Only available in the constructor because it may not be
557 * set after Flash Player has been embedded in the page.
563 * @description Minimum required version for the SWF file. Only available in the constructor because it may not be
564 * set after Flash Player has been embedded in the page.
569 * @attribute backgroundColor
570 * @description The background color of the SWF. Only available in the constructor because it may not be
571 * set after Flash Player has been embedded in the page.
577 * @description Absolute or relative URL to the SWF displayed by the FlashAdapter. Only available in the constructor because it may not be
578 * set after Flash Player has been embedded in the page.
581 this.getAttributeConfig("swfURL",
583 method
: this._getSWFURL
588 * Getter for swfURL attribute.
593 _getSWFURL: function()
600 * Receives event messages from SWF and passes them to the correct instance
603 * @method YAHOO.widget.FlashAdapter.eventHandler
607 YAHOO
.widget
.FlashAdapter
.eventHandler = function(elementID
, event
)
609 var loadedSWF
= YAHOO
.util
.Dom
.get(elementID
);
612 //fix for ie: if owner doesn't exist yet, try again in a moment
613 setTimeout(function() { YAHOO
.widget
.FlashAdapter
.eventHandler( elementID
, event
); }, 0);
617 loadedSWF
.owner
._eventHandler(event
);
622 * The number of proxy functions that have been created.
626 YAHOO
.widget
.FlashAdapter
.proxyFunctionCount
= 0;
629 * Creates a globally accessible function that wraps a function reference.
630 * Returns the proxy function's name as a string for use by the SWF through
633 * @method YAHOO.widget.FlashAdapter.createProxyFunction
637 YAHOO
.widget
.FlashAdapter
.createProxyFunction = function(func
)
639 var index
= YAHOO
.widget
.FlashAdapter
.proxyFunctionCount
;
640 YAHOO
.widget
.FlashAdapter
["proxyFunction" + index
] = function()
642 return func
.apply(null, arguments
);
644 YAHOO
.widget
.FlashAdapter
.proxyFunctionCount
++;
645 return "YAHOO.widget.FlashAdapter.proxyFunction" + index
.toString();
649 * Removes a function created with createProxyFunction()
651 * @method YAHOO.widget.FlashAdapter.removeProxyFunction
655 YAHOO
.widget
.FlashAdapter
.removeProxyFunction = function(funcName
)
658 if(!funcName
|| funcName
.indexOf("YAHOO.widget.FlashAdapter.proxyFunction") < 0)
663 funcName
= funcName
.substr(26);
664 YAHOO
.widget
.FlashAdapter
[funcName
] = null;
668 * The Charts widget provides a Flash control for displaying data
669 * graphically by series across A-grade browsers with Flash Player installed.
672 * @requires yahoo, dom, event, datasource
673 * @title Charts Widget
678 * Chart class for the YUI Charts widget.
680 * @namespace YAHOO.widget
682 * @uses YAHOO.util.FlashAdapter
684 * @param type {String} The char type. May be "line", "column", "bar", or "pie"
685 * @param containerId {HTMLElement} Container element for the Flash Player instance.
686 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
687 * @param attributes {object} (optional) Object literal of configuration values.
689 YAHOO
.widget
.Chart = function(type
, containerId
, dataSource
, attributes
)
691 YAHOO
.widget
.Chart
.superclass
.constructor.call(this, YAHOO
.widget
.Chart
.SWFURL
, containerId
, attributes
);
694 this._dataSource
= dataSource
;
697 * Fires when the user moves the mouse over the bounds of an item renderer in the chart.
699 * @event itemMouseOverEvent
700 * @param event.type {String} The event type
701 * @param event.item {Object} The data displayed by the renderer
702 * @param event.index {Number} The position within the series that the item appears.
703 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
704 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
705 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
707 this.createEvent("itemMouseOverEvent");
710 * Fires when the user moves the mouse out of the bounds of an item renderer in the chart.
712 * @event itemMouseOutEvent
713 * @param event.type {String} The event type
714 * @param event.item {Object} The data displayed by the renderer
715 * @param event.index {Number} The position within the series that the item appears.
716 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
717 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
718 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
720 this.createEvent("itemMouseOutEvent");
723 * Fires when the user clicks an item renderer in the chart with the mouse.
725 * @event itemClickEvent
726 * @param event.type {String} The event type
727 * @param event.item {Object} The data displayed by the renderer
728 * @param event.index {Number} The position within the series that the item appears.
729 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
730 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
731 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
733 this.createEvent("itemClickEvent");
736 * Fires when the user double-clicks an item renderer in the chart with the mouse.
738 * @event itemDoubleClickEvent
739 * @param event.type {String} The event type
740 * @param event.item {Object} The data displayed by the renderer
741 * @param event.index {Number} The position within the series that the item appears.
742 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
743 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
744 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
746 this.createEvent("itemDoubleClickEvent");
749 * Fires when the user presses the mouse down on an item to initiate a drag action.
751 * @event itemDragStartEvent
752 * @param event.type {String} The event type
753 * @param event.item {Object} The data displayed by the renderer
754 * @param event.index {Number} The position within the series that the item appears.
755 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
756 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
757 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
759 this.createEvent("itemDragStartEvent");
762 * Fires when the user moves the mouse during a drag action.
764 * @event itemDragEvent
765 * @param event.type {String} The event type
766 * @param event.item {Object} The data displayed by the renderer
767 * @param event.index {Number} The position within the series that the item appears.
768 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
769 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
770 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
772 this.createEvent("itemDragEvent");
775 * Fires when the user releases the mouse during a drag action.
777 * @event itemDragEndEvent
778 * @param event.type {String} The event type
779 * @param event.item {Object} The data displayed by the renderer
780 * @param event.index {Number} The position within the series that the item appears.
781 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
782 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
783 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
785 this.createEvent("itemDragEndEvent");
788 YAHOO
.extend(YAHOO
.widget
.Chart
, YAHOO
.widget
.FlashAdapter
,
791 * The type of this chart instance.
799 * The id returned from the DataSource's setInterval function.
800 * @property _pollingID
807 * The time, in ms, between requests for data.
808 * @property _pollingInterval
812 _pollingInterval
: null,
815 * Indicates whether all attributes have been set and
816 * the dataSource may be passed to the SWF.
817 * @property _initialized
824 * Stores a reference to the dataTipFunction created by
825 * YAHOO.widget.FlashAdapter.createProxyFunction()
826 * @property _dataTipFunction
830 _dataTipFunction
: null,
833 * Public accessor to the unique name of the Chart instance.
836 * @return {String} Unique name of the Chart instance.
840 return "Chart " + this._id
;
844 * Sets a single style value on the Chart instance.
847 * @param name {String} Name of the Chart style value to change.
848 * @param value {Object} New value to pass to the Chart style.
850 setStyle: function(name
, value
)
852 //we must jsonify this because Flash Player versions below 9.0.60 don't handle
853 //complex ExternalInterface parsing correctly
854 value
= YAHOO
.lang
.JSON
.stringify(value
);
855 this._swf
.setStyle(name
, value
);
859 * Resets all styles on the Chart instance.
862 * @param styles {Object} Initializer for all Chart styles.
864 setStyles: function(styles
)
866 //we must jsonify this because Flash Player versions below 9.0.60 don't handle
867 //complex ExternalInterface parsing correctly
868 styles
= YAHOO
.lang
.JSON
.stringify(styles
);
869 this._swf
.setStyles(styles
);
873 * Sets the styles on all series in the Chart.
875 * @method setSeriesStyles
876 * @param styles {Array} Initializer for all Chart series styles.
878 setSeriesStyles: function(styles
)
880 //we must jsonify this because Flash Player versions below 9.0.60 don't handle
881 //complex ExternalInterface parsing correctly
882 for(var i
= 0; i
< styles
.length
; i
++)
884 styles
[i
] = YAHOO
.lang
.JSON
.stringify(styles
[i
]);
886 this._swf
.setSeriesStyles(styles
);
891 //stop polling if needed
892 if(this._dataSource
!== null)
894 if(this._pollingID
!== null)
896 this._dataSource
.clearInterval(this._pollingID
);
897 this._pollingID
= null;
901 //remove proxy functions
902 if(this._dataTipFunction
)
904 YAHOO
.widget
.FlashAdapter
.removeProxyFunction(this._dataTipFunction
);
908 YAHOO
.widget
.Chart
.superclass
.destroy
.call(this);
912 * Initializes the attributes.
914 * @method _initAttributes
917 _initAttributes: function(attributes
)
919 YAHOO
.widget
.Chart
.superclass
._initAttributes
.call(this, attributes
);
923 * @description Request to be sent to the Chart's DataSource.
926 this.getAttributeConfig("request",
928 method
: this._getRequest
931 this.setAttributeConfig("request",
933 method
: this._setRequest
937 * @attribute dataSource
938 * @description The DataSource instance to display in the Chart.
941 this.getAttributeConfig("dataSource",
943 method
: this._getDataSource
946 this.setAttributeConfig("dataSource",
948 method
: this._setDataSource
953 * @description Defines the series to be displayed by the Chart.
956 this.getAttributeConfig("series",
958 method
: this._getSeriesDefs
961 this.setAttributeConfig("series",
963 method
: this._setSeriesDefs
967 * @attribute categoryNames
968 * @description Defines the names of the categories to be displayed in the Chart..
971 this.getAttributeConfig("categoryNames",
973 method
: this._getCategoryNames
976 this.setAttributeConfig("categoryNames",
978 validator
: YAHOO
.lang
.isArray
,
979 method
: this._setCategoryNames
983 * @attribute dataTipFunction
984 * @description The string representation of a globally-accessible function
985 * that may be called by the SWF to generate the datatip text for a Chart's item.
988 this.getAttributeConfig("dataTipFunction",
990 method
: this._getDataTipFunction
993 this.setAttributeConfig("dataTipFunction",
995 method
: this._setDataTipFunction
1000 * @description A numeric value indicating the number of milliseconds between
1001 * polling requests to the DataSource.
1004 this.getAttributeConfig("polling",
1006 method
: this._getPolling
1009 this.setAttributeConfig("polling",
1011 method
: this._setPolling
1016 * Called when the SWF is ready for communication. Sets the type, initializes
1017 * the styles, and sets the DataSource.
1019 * @method _loadHandler
1022 _loadHandler: function()
1024 this._swf
.setType(this._type
);
1026 //set initial styles
1027 if(this._attributes
.style
)
1029 var style
= this._attributes
.style
;
1030 this.setStyles(style
);
1033 YAHOO
.widget
.Chart
.superclass
._loadHandler
.call(this);
1035 this._initialized
= true;
1037 if(this._dataSource
)
1039 this.set("dataSource", this._dataSource
);
1044 * Sends the request to the DataSource.
1046 * @method _refreshData
1049 _refreshData: function()
1051 if(!this._initialized
)
1056 if(this._dataSource
!== null)
1058 if(this._pollingID
!== null)
1060 this._dataSource
.clearInterval(this._pollingID
);
1061 this._pollingID
= null;
1064 if(this._pollingInterval
> 0)
1066 this._pollingID
= this._dataSource
.setInterval(this._pollingInterval
, this._request
, this._loadDataHandler
, this);
1068 this._dataSource
.sendRequest(this._request
, this._loadDataHandler
, this);
1073 * Called when the DataSource receives new data. The series definitions are used
1074 * to build a data provider for the SWF chart.
1076 * @method _loadDataHandler
1079 _loadDataHandler: function(request
, response
, error
)
1086 var styleChanged
= false;
1088 //make a copy of the series definitions so that we aren't
1089 //editing them directly.
1090 var dataProvider
= [];
1091 var seriesCount
= 0;
1092 var currentSeries
= null;
1094 if(this._seriesDefs
!== null)
1096 seriesCount
= this._seriesDefs
.length
;
1097 for(i
= 0; i
< seriesCount
; i
++)
1099 currentSeries
= this._seriesDefs
[i
];
1100 var clonedSeries
= {};
1101 for(var prop
in currentSeries
)
1103 if(YAHOO
.lang
.hasOwnProperty(currentSeries
, prop
))
1105 if(prop
== "style" && currentSeries
.style
!== null)
1107 clonedSeries
.style
= YAHOO
.lang
.JSON
.stringify(currentSeries
.style
);
1108 styleChanged
= true;
1110 //we don't want to modify the styles again next time
1111 //so null out the style property.
1112 currentSeries
.style
= null;
1116 clonedSeries
[prop
] = currentSeries
[prop
];
1120 dataProvider
.push(clonedSeries
);
1126 for(i
= 0; i
< seriesCount
; i
++)
1128 currentSeries
= dataProvider
[i
];
1129 if(!currentSeries
.type
)
1131 currentSeries
.type
= this._type
;
1133 currentSeries
.dataProvider
= response
.results
;
1138 var series
= {type
: this._type
, dataProvider
: response
.results
};
1139 dataProvider
.push(series
);
1141 this._swf
.setDataProvider(dataProvider
, styleChanged
);
1146 * Storage for the request attribute.
1148 * @property _request
1154 * Getter for the request attribute.
1156 * @method _getRequest
1159 _getRequest: function()
1161 return this._request
;
1165 * Setter for the request attribute.
1167 * @method _setRequest
1170 _setRequest: function(value
)
1172 this._request
= value
;
1173 this._refreshData();
1177 * Storage for the dataSource attribute.
1179 * @property _dataSource
1185 * Getter for the dataSource attribute.
1187 * @method _getDataSource
1190 _getDataSource: function()
1192 return this._dataSource
;
1196 * Setter for the dataSource attribute.
1198 * @method _setDataSource
1201 _setDataSource: function(value
)
1203 this._dataSource
= value
;
1204 this._refreshData();
1208 * Storage for the series attribute.
1210 * @property _seriesDefs
1216 * Getter for the series attribute.
1218 * @method _getSeriesDefs
1221 _getSeriesDefs: function()
1223 return this._seriesDefs
;
1227 * Setter for the series attribute.
1229 * @method _setSeriesDefs
1232 _setSeriesDefs: function(value
)
1234 this._seriesDefs
= value
;
1235 this._refreshData();
1239 * Getter for the categoryNames attribute.
1241 * @method _getCategoryNames
1244 _getCategoryNames: function()
1246 this._swf
.getCategoryNames();
1250 * Setter for the categoryNames attribute.
1252 * @method _setCategoryNames
1255 _setCategoryNames: function(value
)
1257 this._swf
.setCategoryNames(value
);
1261 * Setter for the dataTipFunction attribute.
1263 * @method _setDataTipFunction
1266 _setDataTipFunction: function(value
)
1268 if(this._dataTipFunction
)
1270 YAHOO
.widget
.FlashAdapter
.removeProxyFunction(this._dataTipFunction
);
1273 if(value
&& typeof value
== "function")
1275 value
= YAHOO
.widget
.FlashAdapter
.createProxyFunction(value
);
1276 this._dataTipFunction
= value
;
1278 this._swf
.setDataTipFunction(value
);
1282 * Getter for the polling attribute.
1284 * @method _getPolling
1287 _getPolling: function()
1289 return this._pollingInterval
;
1293 * Setter for the polling attribute.
1295 * @method _setPolling
1298 _setPolling: function(value
)
1300 this._pollingInterval
= value
;
1301 this._refreshData();
1306 * Storage for the dataTipFunction attribute.
1308 * @property Chart.SWFURL
1312 * @default "assets/charts.swf"
1314 YAHOO
.widget
.Chart
.SWFURL
= "assets/charts.swf";
1317 * PieChart class for the YUI Charts widget.
1319 * @namespace YAHOO.widget
1321 * @uses YAHOO.widget.Chart
1323 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1324 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1325 * @param attributes {object} (optional) Object literal of configuration values.
1327 YAHOO
.widget
.PieChart = function(containerId
, dataSource
, attributes
)
1329 YAHOO
.widget
.PieChart
.superclass
.constructor.call(this, "pie", containerId
, dataSource
, attributes
);
1332 YAHOO
.lang
.extend(YAHOO
.widget
.PieChart
, YAHOO
.widget
.Chart
,
1335 * Initializes the attributes.
1337 * @method _initAttributes
1340 _initAttributes: function(attributes
)
1342 YAHOO
.widget
.PieChart
.superclass
._initAttributes
.call(this, attributes
);
1345 * @attribute dataField
1346 * @description The field in each item that corresponds to the data value.
1349 this.getAttributeConfig("dataField",
1351 method
: this._getDataField
1354 this.setAttributeConfig("dataField",
1356 validator
: YAHOO
.lang
.isString
,
1357 method
: this._setDataField
1361 * @attribute categoryField
1362 * @description The field in each item that corresponds to the category value.
1365 this.getAttributeConfig("categoryField",
1367 method
: this._getCategoryField
1370 this.setAttributeConfig("categoryField",
1372 validator
: YAHOO
.lang
.isString
,
1373 method
: this._setCategoryField
1378 * Getter for the dataField attribute.
1380 * @method _getDataField
1383 _getDataField: function()
1385 return this._swf
.getDataField();
1389 * Setter for the dataField attribute.
1391 * @method _setDataField
1394 _setDataField: function(value
)
1396 this._swf
.setDataField(value
);
1400 * Getter for the categoryField attribute.
1402 * @method _getCategoryField
1405 _getCategoryField: function()
1407 return this._swf
.getCategoryField();
1411 * Setter for the categoryField attribute.
1413 * @method _setCategoryField
1416 _setCategoryField: function(value
)
1418 this._swf
.setCategoryField(value
);
1423 * CartesianChart class for the YUI Charts widget.
1425 * @namespace YAHOO.widget
1426 * @class CartesianChart
1427 * @uses YAHOO.widget.Charts
1429 * @param type {String} The char type. May be "line", "column", or "bar"
1430 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1431 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1432 * @param attributes {object} (optional) Object literal of configuration values.
1434 YAHOO
.widget
.CartesianChart = function(type
, containerId
, dataSource
, attributes
)
1436 YAHOO
.widget
.CartesianChart
.superclass
.constructor.call(this, type
, containerId
, dataSource
, attributes
);
1439 YAHOO
.lang
.extend(YAHOO
.widget
.CartesianChart
, YAHOO
.widget
.Chart
,
1442 * Stores a reference to the xAxis labelFunction created by
1443 * YAHOO.widget.FlashAdapter.createProxyFunction()
1444 * @property _xAxisLabelFunction
1448 _xAxisLabelFunction
: null,
1451 * Stores a reference to the yAxis labelFunction created by
1452 * YAHOO.widget.FlashAdapter.createProxyFunction()
1453 * @property _yAxisLabelFunction
1457 _yAxisLabelFunction
: null,
1461 //remove proxy functions
1462 if(this._xAxisLabelFunction
)
1464 YAHOO
.widget
.FlashAdapter
.removeProxyFunction(this._xAxisLabelFunction
);
1465 this._xAxisLabelFunction
= null;
1468 if(this._yAxisLabelFunction
)
1470 YAHOO
.widget
.FlashAdapter
.removeProxyFunction(this._yAxisLabelFunction
);
1471 this._yAxisLabelFunction
= null;
1475 YAHOO
.widget
.CartesianChart
.superclass
.destroy
.call(this);
1479 * Initializes the attributes.
1481 * @method _initAttributes
1484 _initAttributes: function(attributes
)
1486 YAHOO
.widget
.CartesianChart
.superclass
._initAttributes
.call(this, attributes
);
1490 * @description The field in each item that corresponds to a value on the x axis.
1493 this.getAttributeConfig("xField",
1495 method
: this._getXField
1498 this.setAttributeConfig("xField",
1500 validator
: YAHOO
.lang
.isString
,
1501 method
: this._setXField
1506 * @description The field in each item that corresponds to a value on the x axis.
1509 this.getAttributeConfig("yField",
1511 method
: this._getYField
1514 this.setAttributeConfig("yField",
1516 validator
: YAHOO
.lang
.isString
,
1517 method
: this._setYField
1522 * @description A custom configuration for the horizontal x axis.
1525 this.setAttributeConfig("xAxis",
1527 method
: this._setXAxis
1532 * @description A custom configuration for the vertical y axis.
1535 this.setAttributeConfig("yAxis",
1537 method
: this._setYAxis
1542 * Getter for the xField attribute.
1544 * @method _getXField
1547 _getXField: function()
1549 return this._swf
.getHorizontalField();
1553 * Setter for the xField attribute.
1555 * @method _setXField
1558 _setXField: function(value
)
1560 this._swf
.setHorizontalField(value
);
1564 * Getter for the yField attribute.
1566 * @method _getYField
1569 _getYField: function()
1571 return this._swf
.getVerticalField();
1575 * Setter for the yField attribute.
1577 * @method _setYField
1580 _setYField: function(value
)
1582 this._swf
.setVerticalField(value
);
1586 * Setter for the xAxis attribute.
1591 _setXAxis: function(value
)
1593 if(this._xAxisLabelFunction
)
1595 YAHOO
.widget
.FlashAdapter
.removeProxyFunction(this._xAxisLabelFunction
);
1598 if(value
.labelFunction
&& typeof value
.labelFunction
== "function")
1600 value
.labelFunction
= YAHOO
.widget
.FlashAdapter
.createProxyFunction(value
);
1601 this._xAxisLabelFunction
= value
.labelFunction
;
1603 this._swf
.setHorizontalAxis(value
);
1607 * Getter for the yAxis attribute.
1612 _setYAxis: function(value
)
1614 if(this._yAxisLabelFunction
)
1616 YAHOO
.widget
.FlashAdapter
.removeProxyFunction(this._yAxisLabelFunction
);
1619 if(value
.labelFunction
&& typeof value
.labelFunction
== "function")
1621 value
.labelFunction
= YAHOO
.widget
.FlashAdapter
.createProxyFunction(value
.labelFunction
);
1622 this._yAxisLabelFunction
= value
.labelFunction
;
1624 this._swf
.setVerticalAxis(value
);
1629 * LineChart class for the YUI Charts widget.
1631 * @namespace YAHOO.widget
1633 * @uses YAHOO.widget.CartesianChart
1635 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1636 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1637 * @param attributes {object} (optional) Object literal of configuration values.
1639 YAHOO
.widget
.LineChart = function(containerId
, dataSource
, attributes
)
1641 YAHOO
.widget
.LineChart
.superclass
.constructor.call(this, "line", containerId
, dataSource
, attributes
);
1644 YAHOO
.lang
.extend(YAHOO
.widget
.LineChart
, YAHOO
.widget
.CartesianChart
);
1647 * ColumnChart class for the YUI Charts widget.
1649 * @namespace YAHOO.widget
1650 * @class ColumnChart
1651 * @uses YAHOO.widget.CartesianChart
1653 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1654 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1655 * @param attributes {object} (optional) Object literal of configuration values.
1657 YAHOO
.widget
.ColumnChart = function(containerId
, dataSource
, attributes
)
1659 YAHOO
.widget
.ColumnChart
.superclass
.constructor.call(this, "column", containerId
, dataSource
, attributes
);
1662 YAHOO
.lang
.extend(YAHOO
.widget
.ColumnChart
, YAHOO
.widget
.CartesianChart
);
1665 * BarChart class for the YUI Charts widget.
1667 * @namespace YAHOO.widget
1669 * @uses YAHOO.widget.CartesianChart
1671 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1672 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1673 * @param attributes {object} (optional) Object literal of configuration values.
1675 YAHOO
.widget
.BarChart = function(containerId
, dataSource
, attributes
)
1677 YAHOO
.widget
.BarChart
.superclass
.constructor.call(this, "bar", containerId
, dataSource
, attributes
);
1680 YAHOO
.lang
.extend(YAHOO
.widget
.BarChart
, YAHOO
.widget
.CartesianChart
);
1683 * Defines a CartesianChart's vertical or horizontal axis.
1685 * @namespace YAHOO.widget
1689 YAHOO
.widget
.Axis = function()
1693 YAHOO
.widget
.Axis
.prototype =
1704 * The direction in which the axis is drawn. May be "horizontal" or "vertical".
1706 * @property orientation
1709 orientation
: "horizontal",
1712 * If true, the items on the axis will be drawn in opposite direction.
1720 * A string reference to the globally-accessible function that may be called to
1721 * determine each of the label values for this axis.
1723 * @property labelFunction
1726 labelFunction
: null,
1729 * If true, labels that overlap previously drawn labels on the axis will be hidden.
1731 * @property hideOverlappingLabels
1734 hideOverlappingLabels
: true
1738 * A type of axis whose units are measured in numeric values.
1740 * @namespace YAHOO.widget
1741 * @class NumericAxis
1744 YAHOO
.widget
.NumericAxis = function()
1746 YAHOO
.widget
.NumericAxis
.superclass
.constructor.call(this);
1749 YAHOO
.lang
.extend(YAHOO
.widget
.NumericAxis
, YAHOO
.widget
.Axis
,
1754 * The minimum value drawn by the axis. If not set explicitly, the axis minimum
1755 * will be calculated automatically.
1763 * The maximum value drawn by the axis. If not set explicitly, the axis maximum
1764 * will be calculated automatically.
1772 * The spacing between major intervals on this axis.
1774 * @property majorUnit
1780 * The spacing between minor intervals on this axis.
1782 * @property minorUnit
1788 * If true, the labels, ticks, gridlines, and other objects will snap to
1789 * the nearest major or minor unit. If false, their position will be based
1790 * on the minimum value.
1792 * @property snapToUnits
1798 * If true, and the bounds are calculated automatically, either the minimum or
1799 * maximum will be set to zero.
1801 * @property alwaysShowZero
1804 alwaysShowZero
: true,
1807 * The scaling algorithm to use on this axis. May be "linear" or "logarithmic".
1816 * A type of axis whose units are measured in time-based values.
1818 * @namespace YAHOO.widget
1822 YAHOO
.widget
.TimeAxis = function()
1824 YAHOO
.widget
.TimeAxis
.superclass
.constructor.call(this);
1827 YAHOO
.lang
.extend(YAHOO
.widget
.TimeAxis
, YAHOO
.widget
.Axis
,
1832 * The minimum value drawn by the axis. If not set explicitly, the axis minimum
1833 * will be calculated automatically.
1841 * The maximum value drawn by the axis. If not set explicitly, the axis maximum
1842 * will be calculated automatically.
1850 * The spacing between major intervals on this axis.
1852 * @property majorUnit
1858 * The time unit used by the majorUnit.
1860 * @property majorTimeUnit
1863 majorTimeUnit
: null,
1866 * The spacing between minor intervals on this axis.
1868 * @property majorUnit
1874 * The time unit used by the minorUnit.
1876 * @property majorTimeUnit
1879 minorTimeUnit
: null,
1882 * If true, the labels, ticks, gridlines, and other objects will snap to
1883 * the nearest major or minor unit. If false, their position will be based
1884 * on the minimum value.
1886 * @property snapToUnits
1893 * A type of axis that displays items in categories.
1895 * @namespace YAHOO.widget
1896 * @class CategoryAxis
1899 YAHOO
.widget
.CategoryAxis = function()
1901 YAHOO
.widget
.CategoryAxis
.superclass
.constructor.call(this);
1904 YAHOO
.lang
.extend(YAHOO
.widget
.CategoryAxis
, YAHOO
.widget
.Axis
,
1909 * A list of category names to display along this axis.
1911 * @property categoryNames
1918 * Series class for the YUI Charts widget.
1920 * @namespace YAHOO.widget
1924 YAHOO
.widget
.Series = function() {};
1926 YAHOO
.widget
.Series
.prototype =
1929 * The type of series.
1937 * The human-readable name of the series.
1939 * @property displayName
1946 * CartesianSeries class for the YUI Charts widget.
1948 * @namespace YAHOO.widget
1949 * @class CartesianSeries
1952 YAHOO
.widget
.CartesianSeries = function()
1954 YAHOO
.widget
.CartesianSeries
.superclass
.constructor.call(this);
1957 YAHOO
.lang
.extend(YAHOO
.widget
.CartesianSeries
, YAHOO
.widget
.Series
,
1960 * The field used to access the x-axis value from the items from the data source.
1968 * The field used to access the y-axis value from the items from the data source.
1977 * ColumnSeries class for the YUI Charts widget.
1979 * @namespace YAHOO.widget
1980 * @class ColumnSeries
1983 YAHOO
.widget
.ColumnSeries = function()
1985 YAHOO
.widget
.ColumnSeries
.superclass
.constructor.call(this);
1988 YAHOO
.lang
.extend(YAHOO
.widget
.ColumnSeries
, YAHOO
.widget
.CartesianSeries
,
1994 * LineSeries class for the YUI Charts widget.
1996 * @namespace YAHOO.widget
2000 YAHOO
.widget
.LineSeries = function()
2002 YAHOO
.widget
.LineSeries
.superclass
.constructor.call(this);
2005 YAHOO
.lang
.extend(YAHOO
.widget
.LineSeries
, YAHOO
.widget
.CartesianSeries
,
2012 * BarSeries class for the YUI Charts widget.
2014 * @namespace YAHOO.widget
2018 YAHOO
.widget
.BarSeries = function()
2020 YAHOO
.widget
.BarSeries
.superclass
.constructor.call(this);
2023 YAHOO
.lang
.extend(YAHOO
.widget
.BarSeries
, YAHOO
.widget
.CartesianSeries
,
2030 * PieSeries class for the YUI Charts widget.
2032 * @namespace YAHOO.widget
2036 YAHOO
.widget
.PieSeries = function()
2038 YAHOO
.widget
.PieSeries
.superclass
.constructor.call(this);
2041 YAHOO
.lang
.extend(YAHOO
.widget
.PieSeries
, YAHOO
.widget
.Series
,
2048 YAHOO
.register("charts", YAHOO
.widget
.Chart
, {version
: "2.5.2", build
: "1076"});