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
))
449 YAHOO
.log("FlashAdapter instance destroyed: " + instanceName
);
453 * Embeds the SWF in the page and associates it with this instance.
458 _embedSWF: function(swfURL
, containerID
, swfID
, version
, backgroundColor
, expressInstall
, wmode
)
460 //standard SWFObject embed
461 var swfObj
= new deconcept
.SWFObject(swfURL
, swfID
, "100%", "100%", version
, backgroundColor
);
465 swfObj
.useExpressInstall(expressInstall
);
468 //make sure we can communicate with ExternalInterface
469 swfObj
.addParam("allowScriptAccess", "always");
473 swfObj
.addParam("wmode", wmode
);
476 //again, a useful ExternalInterface trick
477 swfObj
.addVariable("allowedDomain", document
.location
.hostname
);
479 //tell the SWF which HTML element it is in
480 swfObj
.addVariable("elementID", swfID
);
482 // set the name of the function to call when the swf has an event
483 swfObj
.addVariable("eventHandler", "YAHOO.widget.FlashAdapter.eventHandler");
485 var container
= YAHOO
.util
.Dom
.get(containerID
);
486 var result
= swfObj
.write(container
);
489 this._swf
= YAHOO
.util
.Dom
.get(swfID
);
490 //if successful, let's add an owner property to the SWF reference
491 //this will allow the event handler to communicate with a YAHOO.widget.FlashAdapter
492 this._swf
.owner
= this;
496 YAHOO
.log("Unable to load SWF " + swfURL
);
501 * Handles or re-dispatches events received from the SWF.
503 * @method _eventHandler
506 _eventHandler: function(event
)
508 var type
= event
.type
;
515 YAHOO
.log(event
.message
, event
.category
, this.toString());
519 //be sure to return after your case or the event will automatically fire!
520 this.fireEvent(type
, event
);
524 * Called when the SWF has been initialized.
526 * @method _loadHandler
529 _loadHandler: function()
531 this._initAttributes(this._attributes
);
532 this.setAttributes(this._attributes
, true);
533 this._attributes
= null;
535 this.fireEvent("contentReady");
539 * Initializes the attributes.
541 * @method _initAttributes
544 _initAttributes: function(attributes
)
546 //should be overridden if other attributes need to be set up
550 * @description Sets the window mode of the Flash Player control. May be
551 * "window", "opaque", or "transparent". Only available in the constructor
552 * because it may not be set after Flash Player has been embedded in the page.
557 * @attribute expressInstall
558 * @description URL pointing to a SWF file that handles Flash Player's express
559 * install feature. Only available in the constructor because it may not be
560 * set after Flash Player has been embedded in the page.
566 * @description Minimum required version for the SWF file. Only available in the constructor because it may not be
567 * set after Flash Player has been embedded in the page.
572 * @attribute backgroundColor
573 * @description The background color of the SWF. Only available in the constructor because it may not be
574 * set after Flash Player has been embedded in the page.
580 * @description Absolute or relative URL to the SWF displayed by the FlashAdapter. Only available in the constructor because it may not be
581 * set after Flash Player has been embedded in the page.
584 this.getAttributeConfig("swfURL",
586 method
: this._getSWFURL
591 * Getter for swfURL attribute.
596 _getSWFURL: function()
603 * Receives event messages from SWF and passes them to the correct instance
606 * @method YAHOO.widget.FlashAdapter.eventHandler
610 YAHOO
.widget
.FlashAdapter
.eventHandler = function(elementID
, event
)
612 var loadedSWF
= YAHOO
.util
.Dom
.get(elementID
);
615 //fix for ie: if owner doesn't exist yet, try again in a moment
616 setTimeout(function() { YAHOO
.widget
.FlashAdapter
.eventHandler( elementID
, event
); }, 0);
620 loadedSWF
.owner
._eventHandler(event
);
625 * The number of proxy functions that have been created.
629 YAHOO
.widget
.FlashAdapter
.proxyFunctionCount
= 0;
632 * Creates a globally accessible function that wraps a function reference.
633 * Returns the proxy function's name as a string for use by the SWF through
636 * @method YAHOO.widget.FlashAdapter.createProxyFunction
640 YAHOO
.widget
.FlashAdapter
.createProxyFunction = function(func
)
642 var index
= YAHOO
.widget
.FlashAdapter
.proxyFunctionCount
;
643 YAHOO
.widget
.FlashAdapter
["proxyFunction" + index
] = function()
645 return func
.apply(null, arguments
);
647 YAHOO
.widget
.FlashAdapter
.proxyFunctionCount
++;
648 return "YAHOO.widget.FlashAdapter.proxyFunction" + index
.toString();
652 * Removes a function created with createProxyFunction()
654 * @method YAHOO.widget.FlashAdapter.removeProxyFunction
658 YAHOO
.widget
.FlashAdapter
.removeProxyFunction = function(funcName
)
661 if(!funcName
|| funcName
.indexOf("YAHOO.widget.FlashAdapter.proxyFunction") < 0)
666 funcName
= funcName
.substr(26);
667 YAHOO
.widget
.FlashAdapter
[funcName
] = null;
671 * The Charts widget provides a Flash control for displaying data
672 * graphically by series across A-grade browsers with Flash Player installed.
675 * @requires yahoo, dom, event, datasource
676 * @title Charts Widget
681 * Chart class for the YUI Charts widget.
683 * @namespace YAHOO.widget
685 * @uses YAHOO.util.FlashAdapter
687 * @param type {String} The char type. May be "line", "column", "bar", or "pie"
688 * @param containerId {HTMLElement} Container element for the Flash Player instance.
689 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
690 * @param attributes {object} (optional) Object literal of configuration values.
692 YAHOO
.widget
.Chart = function(type
, containerId
, dataSource
, attributes
)
694 YAHOO
.widget
.Chart
.superclass
.constructor.call(this, YAHOO
.widget
.Chart
.SWFURL
, containerId
, attributes
);
697 this._dataSource
= dataSource
;
700 * Fires when the user moves the mouse over the bounds of an item renderer in the chart.
702 * @event itemMouseOverEvent
703 * @param event.type {String} The event type
704 * @param event.item {Object} The data displayed by the renderer
705 * @param event.index {Number} The position within the series that the item appears.
706 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
707 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
708 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
710 this.createEvent("itemMouseOverEvent");
713 * Fires when the user moves the mouse out of the bounds of an item renderer in the chart.
715 * @event itemMouseOutEvent
716 * @param event.type {String} The event type
717 * @param event.item {Object} The data displayed by the renderer
718 * @param event.index {Number} The position within the series that the item appears.
719 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
720 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
721 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
723 this.createEvent("itemMouseOutEvent");
726 * Fires when the user clicks an item renderer in the chart with the mouse.
728 * @event itemClickEvent
729 * @param event.type {String} The event type
730 * @param event.item {Object} The data displayed by the renderer
731 * @param event.index {Number} The position within the series that the item appears.
732 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
733 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
734 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
736 this.createEvent("itemClickEvent");
739 * Fires when the user double-clicks an item renderer in the chart with the mouse.
741 * @event itemDoubleClickEvent
742 * @param event.type {String} The event type
743 * @param event.item {Object} The data displayed by the renderer
744 * @param event.index {Number} The position within the series that the item appears.
745 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
746 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
747 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
749 this.createEvent("itemDoubleClickEvent");
752 * Fires when the user presses the mouse down on an item to initiate a drag action.
754 * @event itemDragStartEvent
755 * @param event.type {String} The event type
756 * @param event.item {Object} The data displayed by the renderer
757 * @param event.index {Number} The position within the series that the item appears.
758 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
759 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
760 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
762 this.createEvent("itemDragStartEvent");
765 * Fires when the user moves the mouse during a drag action.
767 * @event itemDragEvent
768 * @param event.type {String} The event type
769 * @param event.item {Object} The data displayed by the renderer
770 * @param event.index {Number} The position within the series that the item appears.
771 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
772 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
773 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
775 this.createEvent("itemDragEvent");
778 * Fires when the user releases the mouse during a drag action.
780 * @event itemDragEndEvent
781 * @param event.type {String} The event type
782 * @param event.item {Object} The data displayed by the renderer
783 * @param event.index {Number} The position within the series that the item appears.
784 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
785 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
786 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
788 this.createEvent("itemDragEndEvent");
791 YAHOO
.extend(YAHOO
.widget
.Chart
, YAHOO
.widget
.FlashAdapter
,
794 * The type of this chart instance.
802 * The id returned from the DataSource's setInterval function.
803 * @property _pollingID
810 * The time, in ms, between requests for data.
811 * @property _pollingInterval
815 _pollingInterval
: null,
818 * Indicates whether all attributes have been set and
819 * the dataSource may be passed to the SWF.
820 * @property _initialized
827 * Stores a reference to the dataTipFunction created by
828 * YAHOO.widget.FlashAdapter.createProxyFunction()
829 * @property _dataTipFunction
833 _dataTipFunction
: null,
836 * Public accessor to the unique name of the Chart instance.
839 * @return {String} Unique name of the Chart instance.
843 return "Chart " + this._id
;
847 * Sets a single style value on the Chart instance.
850 * @param name {String} Name of the Chart style value to change.
851 * @param value {Object} New value to pass to the Chart style.
853 setStyle: function(name
, value
)
855 //we must jsonify this because Flash Player versions below 9.0.60 don't handle
856 //complex ExternalInterface parsing correctly
857 value
= YAHOO
.lang
.JSON
.stringify(value
);
858 this._swf
.setStyle(name
, value
);
862 * Resets all styles on the Chart instance.
865 * @param styles {Object} Initializer for all Chart styles.
867 setStyles: function(styles
)
869 //we must jsonify this because Flash Player versions below 9.0.60 don't handle
870 //complex ExternalInterface parsing correctly
871 styles
= YAHOO
.lang
.JSON
.stringify(styles
);
872 this._swf
.setStyles(styles
);
876 * Sets the styles on all series in the Chart.
878 * @method setSeriesStyles
879 * @param styles {Array} Initializer for all Chart series styles.
881 setSeriesStyles: function(styles
)
883 //we must jsonify this because Flash Player versions below 9.0.60 don't handle
884 //complex ExternalInterface parsing correctly
885 for(var i
= 0; i
< styles
.length
; i
++)
887 styles
[i
] = YAHOO
.lang
.JSON
.stringify(styles
[i
]);
889 this._swf
.setSeriesStyles(styles
);
894 //stop polling if needed
895 if(this._dataSource
!== null)
897 if(this._pollingID
!== null)
899 this._dataSource
.clearInterval(this._pollingID
);
900 this._pollingID
= null;
904 //remove proxy functions
905 if(this._dataTipFunction
)
907 YAHOO
.widget
.FlashAdapter
.removeProxyFunction(this._dataTipFunction
);
911 YAHOO
.widget
.Chart
.superclass
.destroy
.call(this);
915 * Initializes the attributes.
917 * @method _initAttributes
920 _initAttributes: function(attributes
)
922 YAHOO
.widget
.Chart
.superclass
._initAttributes
.call(this, attributes
);
926 * @description Request to be sent to the Chart's DataSource.
929 this.getAttributeConfig("request",
931 method
: this._getRequest
934 this.setAttributeConfig("request",
936 method
: this._setRequest
940 * @attribute dataSource
941 * @description The DataSource instance to display in the Chart.
944 this.getAttributeConfig("dataSource",
946 method
: this._getDataSource
949 this.setAttributeConfig("dataSource",
951 method
: this._setDataSource
956 * @description Defines the series to be displayed by the Chart.
959 this.getAttributeConfig("series",
961 method
: this._getSeriesDefs
964 this.setAttributeConfig("series",
966 method
: this._setSeriesDefs
970 * @attribute categoryNames
971 * @description Defines the names of the categories to be displayed in the Chart..
974 this.getAttributeConfig("categoryNames",
976 method
: this._getCategoryNames
979 this.setAttributeConfig("categoryNames",
981 validator
: YAHOO
.lang
.isArray
,
982 method
: this._setCategoryNames
986 * @attribute dataTipFunction
987 * @description The string representation of a globally-accessible function
988 * that may be called by the SWF to generate the datatip text for a Chart's item.
991 this.getAttributeConfig("dataTipFunction",
993 method
: this._getDataTipFunction
996 this.setAttributeConfig("dataTipFunction",
998 method
: this._setDataTipFunction
1002 * @attribute polling
1003 * @description A numeric value indicating the number of milliseconds between
1004 * polling requests to the DataSource.
1007 this.getAttributeConfig("polling",
1009 method
: this._getPolling
1012 this.setAttributeConfig("polling",
1014 method
: this._setPolling
1019 * Called when the SWF is ready for communication. Sets the type, initializes
1020 * the styles, and sets the DataSource.
1022 * @method _loadHandler
1025 _loadHandler: function()
1027 this._swf
.setType(this._type
);
1029 //set initial styles
1030 if(this._attributes
.style
)
1032 var style
= this._attributes
.style
;
1033 this.setStyles(style
);
1036 YAHOO
.widget
.Chart
.superclass
._loadHandler
.call(this);
1038 this._initialized
= true;
1040 if(this._dataSource
)
1042 this.set("dataSource", this._dataSource
);
1047 * Sends the request to the DataSource.
1049 * @method _refreshData
1052 _refreshData: function()
1054 if(!this._initialized
)
1059 if(this._dataSource
!== null)
1061 if(this._pollingID
!== null)
1063 this._dataSource
.clearInterval(this._pollingID
);
1064 this._pollingID
= null;
1067 if(this._pollingInterval
> 0)
1069 this._pollingID
= this._dataSource
.setInterval(this._pollingInterval
, this._request
, this._loadDataHandler
, this);
1071 this._dataSource
.sendRequest(this._request
, this._loadDataHandler
, this);
1076 * Called when the DataSource receives new data. The series definitions are used
1077 * to build a data provider for the SWF chart.
1079 * @method _loadDataHandler
1082 _loadDataHandler: function(request
, response
, error
)
1086 YAHOO
.log("Unable to load data.", "error");
1090 var styleChanged
= false;
1092 //make a copy of the series definitions so that we aren't
1093 //editing them directly.
1094 var dataProvider
= [];
1095 var seriesCount
= 0;
1096 var currentSeries
= null;
1098 if(this._seriesDefs
!== null)
1100 seriesCount
= this._seriesDefs
.length
;
1101 for(i
= 0; i
< seriesCount
; i
++)
1103 currentSeries
= this._seriesDefs
[i
];
1104 var clonedSeries
= {};
1105 for(var prop
in currentSeries
)
1107 if(YAHOO
.lang
.hasOwnProperty(currentSeries
, prop
))
1109 if(prop
== "style" && currentSeries
.style
!== null)
1111 clonedSeries
.style
= YAHOO
.lang
.JSON
.stringify(currentSeries
.style
);
1112 styleChanged
= true;
1114 //we don't want to modify the styles again next time
1115 //so null out the style property.
1116 currentSeries
.style
= null;
1120 clonedSeries
[prop
] = currentSeries
[prop
];
1124 dataProvider
.push(clonedSeries
);
1130 for(i
= 0; i
< seriesCount
; i
++)
1132 currentSeries
= dataProvider
[i
];
1133 if(!currentSeries
.type
)
1135 currentSeries
.type
= this._type
;
1137 currentSeries
.dataProvider
= response
.results
;
1142 var series
= {type
: this._type
, dataProvider
: response
.results
};
1143 dataProvider
.push(series
);
1145 this._swf
.setDataProvider(dataProvider
, styleChanged
);
1150 * Storage for the request attribute.
1152 * @property _request
1158 * Getter for the request attribute.
1160 * @method _getRequest
1163 _getRequest: function()
1165 return this._request
;
1169 * Setter for the request attribute.
1171 * @method _setRequest
1174 _setRequest: function(value
)
1176 this._request
= value
;
1177 this._refreshData();
1181 * Storage for the dataSource attribute.
1183 * @property _dataSource
1189 * Getter for the dataSource attribute.
1191 * @method _getDataSource
1194 _getDataSource: function()
1196 return this._dataSource
;
1200 * Setter for the dataSource attribute.
1202 * @method _setDataSource
1205 _setDataSource: function(value
)
1207 this._dataSource
= value
;
1208 this._refreshData();
1212 * Storage for the series attribute.
1214 * @property _seriesDefs
1220 * Getter for the series attribute.
1222 * @method _getSeriesDefs
1225 _getSeriesDefs: function()
1227 return this._seriesDefs
;
1231 * Setter for the series attribute.
1233 * @method _setSeriesDefs
1236 _setSeriesDefs: function(value
)
1238 this._seriesDefs
= value
;
1239 this._refreshData();
1243 * Getter for the categoryNames attribute.
1245 * @method _getCategoryNames
1248 _getCategoryNames: function()
1250 this._swf
.getCategoryNames();
1254 * Setter for the categoryNames attribute.
1256 * @method _setCategoryNames
1259 _setCategoryNames: function(value
)
1261 this._swf
.setCategoryNames(value
);
1265 * Setter for the dataTipFunction attribute.
1267 * @method _setDataTipFunction
1270 _setDataTipFunction: function(value
)
1272 if(this._dataTipFunction
)
1274 YAHOO
.widget
.FlashAdapter
.removeProxyFunction(this._dataTipFunction
);
1277 if(value
&& typeof value
== "function")
1279 value
= YAHOO
.widget
.FlashAdapter
.createProxyFunction(value
);
1280 this._dataTipFunction
= value
;
1282 this._swf
.setDataTipFunction(value
);
1286 * Getter for the polling attribute.
1288 * @method _getPolling
1291 _getPolling: function()
1293 return this._pollingInterval
;
1297 * Setter for the polling attribute.
1299 * @method _setPolling
1302 _setPolling: function(value
)
1304 this._pollingInterval
= value
;
1305 this._refreshData();
1310 * Storage for the dataTipFunction attribute.
1312 * @property Chart.SWFURL
1316 * @default "assets/charts.swf"
1318 YAHOO
.widget
.Chart
.SWFURL
= "assets/charts.swf";
1321 * PieChart class for the YUI Charts widget.
1323 * @namespace YAHOO.widget
1325 * @uses YAHOO.widget.Chart
1327 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1328 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1329 * @param attributes {object} (optional) Object literal of configuration values.
1331 YAHOO
.widget
.PieChart = function(containerId
, dataSource
, attributes
)
1333 YAHOO
.widget
.PieChart
.superclass
.constructor.call(this, "pie", containerId
, dataSource
, attributes
);
1336 YAHOO
.lang
.extend(YAHOO
.widget
.PieChart
, YAHOO
.widget
.Chart
,
1339 * Initializes the attributes.
1341 * @method _initAttributes
1344 _initAttributes: function(attributes
)
1346 YAHOO
.widget
.PieChart
.superclass
._initAttributes
.call(this, attributes
);
1349 * @attribute dataField
1350 * @description The field in each item that corresponds to the data value.
1353 this.getAttributeConfig("dataField",
1355 method
: this._getDataField
1358 this.setAttributeConfig("dataField",
1360 validator
: YAHOO
.lang
.isString
,
1361 method
: this._setDataField
1365 * @attribute categoryField
1366 * @description The field in each item that corresponds to the category value.
1369 this.getAttributeConfig("categoryField",
1371 method
: this._getCategoryField
1374 this.setAttributeConfig("categoryField",
1376 validator
: YAHOO
.lang
.isString
,
1377 method
: this._setCategoryField
1382 * Getter for the dataField attribute.
1384 * @method _getDataField
1387 _getDataField: function()
1389 return this._swf
.getDataField();
1393 * Setter for the dataField attribute.
1395 * @method _setDataField
1398 _setDataField: function(value
)
1400 this._swf
.setDataField(value
);
1404 * Getter for the categoryField attribute.
1406 * @method _getCategoryField
1409 _getCategoryField: function()
1411 return this._swf
.getCategoryField();
1415 * Setter for the categoryField attribute.
1417 * @method _setCategoryField
1420 _setCategoryField: function(value
)
1422 this._swf
.setCategoryField(value
);
1427 * CartesianChart class for the YUI Charts widget.
1429 * @namespace YAHOO.widget
1430 * @class CartesianChart
1431 * @uses YAHOO.widget.Charts
1433 * @param type {String} The char type. May be "line", "column", or "bar"
1434 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1435 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1436 * @param attributes {object} (optional) Object literal of configuration values.
1438 YAHOO
.widget
.CartesianChart = function(type
, containerId
, dataSource
, attributes
)
1440 YAHOO
.widget
.CartesianChart
.superclass
.constructor.call(this, type
, containerId
, dataSource
, attributes
);
1443 YAHOO
.lang
.extend(YAHOO
.widget
.CartesianChart
, YAHOO
.widget
.Chart
,
1446 * Stores a reference to the xAxis labelFunction created by
1447 * YAHOO.widget.FlashAdapter.createProxyFunction()
1448 * @property _xAxisLabelFunction
1452 _xAxisLabelFunction
: null,
1455 * Stores a reference to the yAxis labelFunction created by
1456 * YAHOO.widget.FlashAdapter.createProxyFunction()
1457 * @property _yAxisLabelFunction
1461 _yAxisLabelFunction
: null,
1465 //remove proxy functions
1466 if(this._xAxisLabelFunction
)
1468 YAHOO
.widget
.FlashAdapter
.removeProxyFunction(this._xAxisLabelFunction
);
1469 this._xAxisLabelFunction
= null;
1472 if(this._yAxisLabelFunction
)
1474 YAHOO
.widget
.FlashAdapter
.removeProxyFunction(this._yAxisLabelFunction
);
1475 this._yAxisLabelFunction
= null;
1479 YAHOO
.widget
.CartesianChart
.superclass
.destroy
.call(this);
1483 * Initializes the attributes.
1485 * @method _initAttributes
1488 _initAttributes: function(attributes
)
1490 YAHOO
.widget
.CartesianChart
.superclass
._initAttributes
.call(this, attributes
);
1494 * @description The field in each item that corresponds to a value on the x axis.
1497 this.getAttributeConfig("xField",
1499 method
: this._getXField
1502 this.setAttributeConfig("xField",
1504 validator
: YAHOO
.lang
.isString
,
1505 method
: this._setXField
1510 * @description The field in each item that corresponds to a value on the x axis.
1513 this.getAttributeConfig("yField",
1515 method
: this._getYField
1518 this.setAttributeConfig("yField",
1520 validator
: YAHOO
.lang
.isString
,
1521 method
: this._setYField
1526 * @description A custom configuration for the horizontal x axis.
1529 this.setAttributeConfig("xAxis",
1531 method
: this._setXAxis
1536 * @description A custom configuration for the vertical y axis.
1539 this.setAttributeConfig("yAxis",
1541 method
: this._setYAxis
1546 * Getter for the xField attribute.
1548 * @method _getXField
1551 _getXField: function()
1553 return this._swf
.getHorizontalField();
1557 * Setter for the xField attribute.
1559 * @method _setXField
1562 _setXField: function(value
)
1564 this._swf
.setHorizontalField(value
);
1568 * Getter for the yField attribute.
1570 * @method _getYField
1573 _getYField: function()
1575 return this._swf
.getVerticalField();
1579 * Setter for the yField attribute.
1581 * @method _setYField
1584 _setYField: function(value
)
1586 this._swf
.setVerticalField(value
);
1590 * Setter for the xAxis attribute.
1595 _setXAxis: function(value
)
1597 if(this._xAxisLabelFunction
)
1599 YAHOO
.widget
.FlashAdapter
.removeProxyFunction(this._xAxisLabelFunction
);
1602 if(value
.labelFunction
&& typeof value
.labelFunction
== "function")
1604 value
.labelFunction
= YAHOO
.widget
.FlashAdapter
.createProxyFunction(value
);
1605 this._xAxisLabelFunction
= value
.labelFunction
;
1607 this._swf
.setHorizontalAxis(value
);
1611 * Getter for the yAxis attribute.
1616 _setYAxis: function(value
)
1618 if(this._yAxisLabelFunction
)
1620 YAHOO
.widget
.FlashAdapter
.removeProxyFunction(this._yAxisLabelFunction
);
1623 if(value
.labelFunction
&& typeof value
.labelFunction
== "function")
1625 value
.labelFunction
= YAHOO
.widget
.FlashAdapter
.createProxyFunction(value
.labelFunction
);
1626 this._yAxisLabelFunction
= value
.labelFunction
;
1628 this._swf
.setVerticalAxis(value
);
1633 * LineChart class for the YUI Charts widget.
1635 * @namespace YAHOO.widget
1637 * @uses YAHOO.widget.CartesianChart
1639 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1640 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1641 * @param attributes {object} (optional) Object literal of configuration values.
1643 YAHOO
.widget
.LineChart = function(containerId
, dataSource
, attributes
)
1645 YAHOO
.widget
.LineChart
.superclass
.constructor.call(this, "line", containerId
, dataSource
, attributes
);
1648 YAHOO
.lang
.extend(YAHOO
.widget
.LineChart
, YAHOO
.widget
.CartesianChart
);
1651 * ColumnChart class for the YUI Charts widget.
1653 * @namespace YAHOO.widget
1654 * @class ColumnChart
1655 * @uses YAHOO.widget.CartesianChart
1657 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1658 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1659 * @param attributes {object} (optional) Object literal of configuration values.
1661 YAHOO
.widget
.ColumnChart = function(containerId
, dataSource
, attributes
)
1663 YAHOO
.widget
.ColumnChart
.superclass
.constructor.call(this, "column", containerId
, dataSource
, attributes
);
1666 YAHOO
.lang
.extend(YAHOO
.widget
.ColumnChart
, YAHOO
.widget
.CartesianChart
);
1669 * BarChart class for the YUI Charts widget.
1671 * @namespace YAHOO.widget
1673 * @uses YAHOO.widget.CartesianChart
1675 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1676 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1677 * @param attributes {object} (optional) Object literal of configuration values.
1679 YAHOO
.widget
.BarChart = function(containerId
, dataSource
, attributes
)
1681 YAHOO
.widget
.BarChart
.superclass
.constructor.call(this, "bar", containerId
, dataSource
, attributes
);
1684 YAHOO
.lang
.extend(YAHOO
.widget
.BarChart
, YAHOO
.widget
.CartesianChart
);
1687 * Defines a CartesianChart's vertical or horizontal axis.
1689 * @namespace YAHOO.widget
1693 YAHOO
.widget
.Axis = function()
1697 YAHOO
.widget
.Axis
.prototype =
1708 * The direction in which the axis is drawn. May be "horizontal" or "vertical".
1710 * @property orientation
1713 orientation
: "horizontal",
1716 * If true, the items on the axis will be drawn in opposite direction.
1724 * A string reference to the globally-accessible function that may be called to
1725 * determine each of the label values for this axis.
1727 * @property labelFunction
1730 labelFunction
: null,
1733 * If true, labels that overlap previously drawn labels on the axis will be hidden.
1735 * @property hideOverlappingLabels
1738 hideOverlappingLabels
: true
1742 * A type of axis whose units are measured in numeric values.
1744 * @namespace YAHOO.widget
1745 * @class NumericAxis
1748 YAHOO
.widget
.NumericAxis = function()
1750 YAHOO
.widget
.NumericAxis
.superclass
.constructor.call(this);
1753 YAHOO
.lang
.extend(YAHOO
.widget
.NumericAxis
, YAHOO
.widget
.Axis
,
1758 * The minimum value drawn by the axis. If not set explicitly, the axis minimum
1759 * will be calculated automatically.
1767 * The maximum value drawn by the axis. If not set explicitly, the axis maximum
1768 * will be calculated automatically.
1776 * The spacing between major intervals on this axis.
1778 * @property majorUnit
1784 * The spacing between minor intervals on this axis.
1786 * @property minorUnit
1792 * If true, the labels, ticks, gridlines, and other objects will snap to
1793 * the nearest major or minor unit. If false, their position will be based
1794 * on the minimum value.
1796 * @property snapToUnits
1802 * If true, and the bounds are calculated automatically, either the minimum or
1803 * maximum will be set to zero.
1805 * @property alwaysShowZero
1808 alwaysShowZero
: true,
1811 * The scaling algorithm to use on this axis. May be "linear" or "logarithmic".
1820 * A type of axis whose units are measured in time-based values.
1822 * @namespace YAHOO.widget
1826 YAHOO
.widget
.TimeAxis = function()
1828 YAHOO
.widget
.TimeAxis
.superclass
.constructor.call(this);
1831 YAHOO
.lang
.extend(YAHOO
.widget
.TimeAxis
, YAHOO
.widget
.Axis
,
1836 * The minimum value drawn by the axis. If not set explicitly, the axis minimum
1837 * will be calculated automatically.
1845 * The maximum value drawn by the axis. If not set explicitly, the axis maximum
1846 * will be calculated automatically.
1854 * The spacing between major intervals on this axis.
1856 * @property majorUnit
1862 * The time unit used by the majorUnit.
1864 * @property majorTimeUnit
1867 majorTimeUnit
: null,
1870 * The spacing between minor intervals on this axis.
1872 * @property majorUnit
1878 * The time unit used by the minorUnit.
1880 * @property majorTimeUnit
1883 minorTimeUnit
: null,
1886 * If true, the labels, ticks, gridlines, and other objects will snap to
1887 * the nearest major or minor unit. If false, their position will be based
1888 * on the minimum value.
1890 * @property snapToUnits
1897 * A type of axis that displays items in categories.
1899 * @namespace YAHOO.widget
1900 * @class CategoryAxis
1903 YAHOO
.widget
.CategoryAxis = function()
1905 YAHOO
.widget
.CategoryAxis
.superclass
.constructor.call(this);
1908 YAHOO
.lang
.extend(YAHOO
.widget
.CategoryAxis
, YAHOO
.widget
.Axis
,
1913 * A list of category names to display along this axis.
1915 * @property categoryNames
1922 * Series class for the YUI Charts widget.
1924 * @namespace YAHOO.widget
1928 YAHOO
.widget
.Series = function() {};
1930 YAHOO
.widget
.Series
.prototype =
1933 * The type of series.
1941 * The human-readable name of the series.
1943 * @property displayName
1950 * CartesianSeries class for the YUI Charts widget.
1952 * @namespace YAHOO.widget
1953 * @class CartesianSeries
1956 YAHOO
.widget
.CartesianSeries = function()
1958 YAHOO
.widget
.CartesianSeries
.superclass
.constructor.call(this);
1961 YAHOO
.lang
.extend(YAHOO
.widget
.CartesianSeries
, YAHOO
.widget
.Series
,
1964 * The field used to access the x-axis value from the items from the data source.
1972 * The field used to access the y-axis value from the items from the data source.
1981 * ColumnSeries class for the YUI Charts widget.
1983 * @namespace YAHOO.widget
1984 * @class ColumnSeries
1987 YAHOO
.widget
.ColumnSeries = function()
1989 YAHOO
.widget
.ColumnSeries
.superclass
.constructor.call(this);
1992 YAHOO
.lang
.extend(YAHOO
.widget
.ColumnSeries
, YAHOO
.widget
.CartesianSeries
,
1998 * LineSeries class for the YUI Charts widget.
2000 * @namespace YAHOO.widget
2004 YAHOO
.widget
.LineSeries = function()
2006 YAHOO
.widget
.LineSeries
.superclass
.constructor.call(this);
2009 YAHOO
.lang
.extend(YAHOO
.widget
.LineSeries
, YAHOO
.widget
.CartesianSeries
,
2016 * BarSeries class for the YUI Charts widget.
2018 * @namespace YAHOO.widget
2022 YAHOO
.widget
.BarSeries = function()
2024 YAHOO
.widget
.BarSeries
.superclass
.constructor.call(this);
2027 YAHOO
.lang
.extend(YAHOO
.widget
.BarSeries
, YAHOO
.widget
.CartesianSeries
,
2034 * PieSeries class for the YUI Charts widget.
2036 * @namespace YAHOO.widget
2040 YAHOO
.widget
.PieSeries = function()
2042 YAHOO
.widget
.PieSeries
.superclass
.constructor.call(this);
2045 YAHOO
.lang
.extend(YAHOO
.widget
.PieSeries
, YAHOO
.widget
.Series
,
2052 YAHOO
.register("charts", YAHOO
.widget
.Chart
, {version
: "2.5.2", build
: "1076"});