PageRenderTime 71ms CodeModel.GetById 16ms app.highlight 44ms RepoModel.GetById 1ms app.codeStats 1ms

/hippo/src/main/webapp/yui/charts/charts-debug.js

http://hdbc.googlecode.com/
JavaScript | 2326 lines | 1077 code | 220 blank | 1029 comment | 134 complexity | 70717a001ae27129bfa7db20ecaf805b MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1/*
   2Copyright (c) 2009, Yahoo! Inc. All rights reserved.
   3Code licensed under the BSD License:
   4http://developer.yahoo.net/yui/license.txt
   5version: 2.7.0
   6*/
   7/*extern ActiveXObject, __flash_unloadHandler, __flash_savedUnloadHandler */
   8/*!
   9 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
  10 *
  11 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
  12 * http://www.opensource.org/licenses/mit-license.php
  13 * @namespace YAHOO
  14 */
  15
  16YAHOO.namespace("deconcept"); 
  17	
  18YAHOO.deconcept = YAHOO.deconcept || {};
  19
  20if(typeof YAHOO.deconcept.util == "undefined" || !YAHOO.deconcept.util)
  21{
  22	YAHOO.deconcept.util = {};
  23}
  24
  25if(typeof YAHOO.deconcept.SWFObjectUtil == "undefined" || !YAHOO.deconcept.SWFObjectUtil)
  26{
  27	YAHOO.deconcept.SWFObjectUtil = {};
  28}
  29
  30YAHOO.deconcept.SWFObject = function(swf, id, w, h, ver, c, quality, xiRedirectUrl, redirectUrl, detectKey)
  31{
  32	if(!document.getElementById) { return; }
  33	this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
  34	this.skipDetect = YAHOO.deconcept.util.getRequestParameter(this.DETECT_KEY);
  35	this.params = {};
  36	this.variables = {};
  37	this.attributes = [];
  38	if(swf) { this.setAttribute('swf', swf); }
  39	if(id) { this.setAttribute('id', id); }
  40	if(w) { this.setAttribute('width', w); }
  41	if(h) { this.setAttribute('height', h); }
  42	if(ver) { this.setAttribute('version', new YAHOO.deconcept.PlayerVersion(ver.toString().split("."))); }
  43	this.installedVer = YAHOO.deconcept.SWFObjectUtil.getPlayerVersion();
  44	if (!window.opera && document.all && this.installedVer.major > 7)
  45	{
  46		// only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
  47		YAHOO.deconcept.SWFObject.doPrepUnload = true;
  48	}
  49	if(c)
  50	{
  51		this.addParam('bgcolor', c);
  52	}
  53	var q = quality ? quality : 'high';
  54	this.addParam('quality', q);
  55	this.setAttribute('useExpressInstall', false);
  56	this.setAttribute('doExpressInstall', false);
  57	var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
  58	this.setAttribute('xiRedirectUrl', xir);
  59	this.setAttribute('redirectUrl', '');
  60	if(redirectUrl)
  61	{
  62		this.setAttribute('redirectUrl', redirectUrl);
  63	}
  64};
  65
  66YAHOO.deconcept.SWFObject.prototype =
  67{
  68	useExpressInstall: function(path)
  69	{
  70		this.xiSWFPath = !path ? "expressinstall.swf" : path;
  71		this.setAttribute('useExpressInstall', true);
  72	},
  73	setAttribute: function(name, value){
  74		this.attributes[name] = value;
  75	},
  76	getAttribute: function(name){
  77		return this.attributes[name];
  78	},
  79	addParam: function(name, value){
  80		this.params[name] = value;
  81	},
  82	getParams: function(){
  83		return this.params;
  84	},
  85	addVariable: function(name, value){
  86		this.variables[name] = value;
  87	},
  88	getVariable: function(name){
  89		return this.variables[name];
  90	},
  91	getVariables: function(){
  92		return this.variables;
  93	},
  94	getVariablePairs: function(){
  95		var variablePairs = [];
  96		var key;
  97		var variables = this.getVariables();
  98		for(key in variables)
  99		{
 100			if(variables.hasOwnProperty(key))
 101			{
 102				variablePairs[variablePairs.length] = key +"="+ variables[key];
 103			}
 104		}
 105		return variablePairs;
 106	},
 107	getSWFHTML: function() {
 108		var swfNode = "";
 109		var params = {};
 110		var key = "";
 111		var pairs = "";
 112		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
 113			if (this.getAttribute("doExpressInstall")) {
 114				this.addVariable("MMplayerType", "PlugIn");
 115				this.setAttribute('swf', this.xiSWFPath);
 116			}
 117			swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'"';
 118			swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
 119			params = this.getParams();
 120			for(key in params)
 121			{
 122				if(params.hasOwnProperty(key))
 123				{
 124					swfNode += [key] +'="'+ params[key] +'" ';
 125				}
 126			}
 127			pairs = this.getVariablePairs().join("&");
 128			if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
 129			swfNode += '/>';
 130		} else { // PC IE
 131			if (this.getAttribute("doExpressInstall")) {
 132				this.addVariable("MMplayerType", "ActiveX");
 133				this.setAttribute('swf', this.xiSWFPath);
 134			}
 135			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') +'">';
 136			swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
 137			params = this.getParams();
 138			for(key in params)
 139			{
 140				if(params.hasOwnProperty(key))
 141				{
 142					swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
 143				}
 144			}
 145			pairs = this.getVariablePairs().join("&");
 146			if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
 147			swfNode += "</object>";
 148		}
 149		return swfNode;
 150	},
 151	write: function(elementId)
 152	{
 153		if(this.getAttribute('useExpressInstall')) {
 154			// check to see if we need to do an express install
 155			var expressInstallReqVer = new YAHOO.deconcept.PlayerVersion([6,0,65]);
 156			if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
 157				this.setAttribute('doExpressInstall', true);
 158				this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
 159				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
 160				this.addVariable("MMdoctitle", document.title);
 161			}
 162		}
 163		if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version')))
 164		{
 165			var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
 166			n.innerHTML = this.getSWFHTML();
 167			return true;
 168		}
 169		else
 170		{
 171			if(this.getAttribute('redirectUrl') !== "")
 172			{
 173				document.location.replace(this.getAttribute('redirectUrl'));
 174			}
 175		}
 176		return false;
 177	}
 178};
 179
 180/* ---- detection functions ---- */
 181YAHOO.deconcept.SWFObjectUtil.getPlayerVersion = function()
 182{
 183	var axo = null;
 184	var PlayerVersion = new YAHOO.deconcept.PlayerVersion([0,0,0]);
 185	if(navigator.plugins && navigator.mimeTypes.length)
 186	{
 187		var x = navigator.plugins["Shockwave Flash"];
 188		if(x && x.description)
 189		{
 190			PlayerVersion = new YAHOO.deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
 191		}
 192	}
 193	else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0)
 194	{ // if Windows CE
 195		var counter = 3;
 196		while(axo)
 197		{
 198			try
 199			{
 200				counter++;
 201				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
 202//				document.write("player v: "+ counter);
 203				PlayerVersion = new YAHOO.deconcept.PlayerVersion([counter,0,0]);
 204			}
 205			catch(e)
 206			{
 207				axo = null;
 208			}
 209		}
 210	}
 211	else
 212	{ // Win IE (non mobile)
 213		// do minor version lookup in IE, but avoid fp6 crashing issues
 214		// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
 215		try
 216		{
 217			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
 218		}
 219		catch(e)
 220		{
 221			try
 222			{
 223				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
 224				PlayerVersion = new YAHOO.deconcept.PlayerVersion([6,0,21]);
 225				axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
 226			}
 227			catch(e)
 228			{
 229				if(PlayerVersion.major == 6)
 230				{
 231					return PlayerVersion;
 232				}
 233			}
 234			try
 235			{
 236				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
 237			}
 238			catch(e) {}
 239		}
 240		
 241		if(axo !== null)
 242		{
 243			PlayerVersion = new YAHOO.deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
 244		}
 245	}
 246	return PlayerVersion;
 247};
 248
 249YAHOO.deconcept.PlayerVersion = function(arrVersion)
 250{
 251	this.major = arrVersion[0] !== null ? parseInt(arrVersion[0], 0) : 0;
 252	this.minor = arrVersion[1] !== null ? parseInt(arrVersion[1], 0) : 0;
 253	this.rev = arrVersion[2] !== null ? parseInt(arrVersion[2], 0) : 0;
 254};
 255
 256YAHOO.deconcept.PlayerVersion.prototype.versionIsValid = function(fv)
 257{
 258	if(this.major < fv.major)
 259	{
 260		return false;
 261	}
 262	if(this.major > fv.major)
 263	{
 264		return true;
 265	}
 266	if(this.minor < fv.minor)
 267	{
 268		return false;
 269	}
 270	if(this.minor > fv.minor)
 271	{
 272		return true;
 273	}
 274	if(this.rev < fv.rev)
 275	{
 276		return false;
 277	}
 278	return true;
 279};
 280
 281/* ---- get value of query string param ---- */
 282YAHOO.deconcept.util =
 283{
 284	getRequestParameter: function(param)
 285	{
 286		var q = document.location.search || document.location.hash;
 287		if(param === null) { return q; }
 288		if(q)
 289		{
 290			var pairs = q.substring(1).split("&");
 291			for(var i=0; i < pairs.length; i++)
 292			{
 293				if (pairs[i].substring(0, pairs[i].indexOf("=")) == param)
 294				{
 295					return pairs[i].substring((pairs[i].indexOf("=") + 1));
 296				}
 297			}
 298		}
 299		return "";
 300	}
 301};
 302
 303/* fix for video streaming bug */
 304YAHOO.deconcept.SWFObjectUtil.cleanupSWFs = function()
 305{
 306	var objects = document.getElementsByTagName("OBJECT");
 307	for(var i = objects.length - 1; i >= 0; i--)
 308	{
 309		objects[i].style.display = 'none';
 310		for(var x in objects[i])
 311		{
 312			if(typeof objects[i][x] == 'function')
 313			{
 314				objects[i][x] = function(){};
 315			}
 316		}
 317	}
 318};
 319
 320// fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
 321if(YAHOO.deconcept.SWFObject.doPrepUnload)
 322{
 323	if(!YAHOO.deconcept.unloadSet)
 324	{
 325		YAHOO.deconcept.SWFObjectUtil.prepUnload = function()
 326		{
 327			__flash_unloadHandler = function(){};
 328			__flash_savedUnloadHandler = function(){};
 329			window.attachEvent("onunload", YAHOO.deconcept.SWFObjectUtil.cleanupSWFs);
 330		};
 331		window.attachEvent("onbeforeunload", YAHOO.deconcept.SWFObjectUtil.prepUnload);
 332		YAHOO.deconcept.unloadSet = true;
 333	}
 334}
 335
 336/* add document.getElementById if needed (mobile IE < 5) */
 337if(!document.getElementById && document.all)
 338{
 339	document.getElementById = function(id) { return document.all[id]; };
 340}
 341
 342
 343/**
 344 * Wraps Flash embedding functionality and allows communication with SWF through
 345 * attributes.
 346 *
 347 * @namespace YAHOO.widget
 348 * @class FlashAdapter
 349 * @uses YAHOO.util.AttributeProvider
 350 */
 351YAHOO.widget.FlashAdapter = function(swfURL, containerID, attributes)
 352{
 353	// set up the initial events and attributes stuff
 354	this._queue = this._queue || [];
 355	this._events = this._events || {};
 356	this._configs = this._configs || {};
 357	attributes = attributes || {};
 358	
 359	//the Flash Player external interface code from Adobe doesn't play nicely
 360	//with the default value, yui-gen, in IE
 361	this._id = attributes.id = attributes.id || YAHOO.util.Dom.generateId(null, "yuigen");
 362	attributes.version = attributes.version || "9.0.45";
 363	attributes.backgroundColor = attributes.backgroundColor || "#ffffff";
 364	
 365	//we can't use the initial attributes right away
 366	//so save them for once the SWF finishes loading
 367	this._attributes = attributes;
 368	
 369	this._swfURL = swfURL;
 370	this._containerID = containerID;
 371	
 372	//embed the SWF file in the page
 373	this._embedSWF(this._swfURL, this._containerID, attributes.id, attributes.version,
 374		attributes.backgroundColor, attributes.expressInstall, attributes.wmode);
 375	
 376	/**
 377	 * Fires when the SWF is initialized and communication is possible.
 378	 * @event contentReady
 379	 */
 380	//Fix for iframe cross-domain issue with FF2x 
 381	try
 382	{
 383		this.createEvent("contentReady");
 384	}
 385	catch(e){}
 386};
 387
 388YAHOO.extend(YAHOO.widget.FlashAdapter, YAHOO.util.AttributeProvider,
 389{
 390	/**
 391	 * The URL of the SWF file.
 392	 * @property _swfURL
 393	 * @type String
 394	 * @private
 395	 */
 396	_swfURL: null,
 397
 398	/**
 399	 * The ID of the containing DIV.
 400	 * @property _containerID
 401	 * @type String
 402	 * @private
 403	 */
 404	_containerID: null,
 405
 406	/**
 407	 * A reference to the embedded SWF file.
 408	 * @property _swf
 409	 * @private
 410	 */
 411	_swf: null,
 412
 413	/**
 414	 * The id of this instance.
 415	 * @property _id
 416	 * @type String
 417	 * @private
 418	 */
 419	_id: null,
 420
 421	/**
 422	 * Indicates whether the SWF has been initialized and is ready
 423	 * to communicate with JavaScript
 424	 * @property _initialized
 425	 * @type Boolean
 426	 * @private
 427	 */
 428	_initialized: false,
 429	
 430	/**
 431	 * The initializing attributes are stored here until the SWF is ready.
 432	 * @property _attributes
 433	 * @type Object
 434	 * @private
 435	 */
 436	_attributes: null, //the intializing attributes
 437
 438	/**
 439	 * Public accessor to the unique name of the FlashAdapter instance.
 440	 *
 441	 * @method toString
 442	 * @return {String} Unique name of the FlashAdapter instance.
 443	 */
 444	toString: function()
 445	{
 446		return "FlashAdapter " + this._id;
 447	},
 448
 449	/**
 450	 * Nulls out the entire FlashAdapter instance and related objects and removes attached
 451	 * event listeners and clears out DOM elements inside the container. After calling
 452	 * this method, the instance reference should be expliclitly nulled by implementer,
 453	 * as in myChart = null. Use with caution!
 454	 *
 455	 * @method destroy
 456	 */
 457	destroy: function()
 458	{
 459		//kill the Flash Player instance
 460		if(this._swf)
 461		{
 462			var container = YAHOO.util.Dom.get(this._containerID);
 463			container.removeChild(this._swf);
 464		}
 465		
 466		var instanceName = this._id;
 467		
 468		//null out properties
 469		for(var prop in this)
 470		{
 471			if(YAHOO.lang.hasOwnProperty(this, prop))
 472			{
 473				this[prop] = null;
 474			}
 475		}
 476		
 477		YAHOO.log("FlashAdapter instance destroyed: " + instanceName);
 478	},
 479
 480	/**
 481	 * Embeds the SWF in the page and associates it with this instance.
 482	 *
 483	 * @method _embedSWF
 484	 * @private
 485	 */
 486	_embedSWF: function(swfURL, containerID, swfID, version, backgroundColor, expressInstall, wmode)
 487	{
 488		//standard SWFObject embed
 489		var swfObj = new YAHOO.deconcept.SWFObject(swfURL, swfID, "100%", "100%", version, backgroundColor);
 490
 491		if(expressInstall)
 492		{
 493			swfObj.useExpressInstall(expressInstall);
 494		}
 495
 496		//make sure we can communicate with ExternalInterface
 497		swfObj.addParam("allowScriptAccess", "always");
 498		
 499		if(wmode)
 500		{
 501			swfObj.addParam("wmode", wmode);
 502		}
 503		
 504		//again, a useful ExternalInterface trick
 505		swfObj.addVariable("allowedDomain", document.location.hostname);
 506
 507		//tell the SWF which HTML element it is in
 508		swfObj.addVariable("elementID", swfID);
 509
 510		// set the name of the function to call when the swf has an event
 511		swfObj.addVariable("eventHandler", "YAHOO.widget.FlashAdapter.eventHandler");
 512
 513		var container = YAHOO.util.Dom.get(containerID);
 514		var result = swfObj.write(container);
 515		if(result)
 516		{
 517			this._swf = YAHOO.util.Dom.get(swfID);
 518			//if successful, let's add an owner property to the SWF reference
 519			//this will allow the event handler to communicate with a YAHOO.widget.FlashAdapter
 520			this._swf.owner = this;
 521		}
 522		else
 523		{
 524			YAHOO.log("Unable to load SWF " + swfURL);
 525		}
 526	},
 527
 528	/**
 529	 * Handles or re-dispatches events received from the SWF.
 530	 *
 531	 * @method _eventHandler
 532	 * @private
 533	 */
 534	_eventHandler: function(event)
 535	{
 536		var type = event.type;
 537		switch(type)
 538		{
 539			case "swfReady":
 540   				this._loadHandler();
 541   				this.fireEvent("contentReady");
 542				return;
 543			case "log":
 544				YAHOO.log(event.message, event.category, this.toString());
 545				return;
 546		}
 547		
 548		//be sure to return after your case or the event will automatically fire!
 549		this.fireEvent(type, event);
 550	},
 551
 552	/**
 553	 * Called when the SWF has been initialized.
 554	 *
 555	 * @method _loadHandler
 556	 * @private
 557	 */
 558	_loadHandler: function()
 559	{
 560		this._initialized = false;
 561		this._initAttributes(this._attributes);
 562		this.setAttributes(this._attributes, true);
 563		
 564		this._initialized = true;
 565	},
 566	
 567	set: function(name, value)
 568	{
 569		//save all the attributes in case the swf reloads
 570		//so that we can pass them in again
 571		this._attributes[name] = value;
 572		YAHOO.widget.FlashAdapter.superclass.set.call(this, name, value);
 573	},
 574	
 575	/**
 576	 * Initializes the attributes.
 577	 *
 578	 * @method _initAttributes
 579	 * @private
 580	 */
 581	_initAttributes: function(attributes)
 582	{
 583		//should be overridden if other attributes need to be set up
 584
 585		/**
 586		 * @attribute wmode
 587		 * @description Sets the window mode of the Flash Player control. May be
 588		 *		"window", "opaque", or "transparent". Only available in the constructor
 589		 *		because it may not be set after Flash Player has been embedded in the page.
 590		 * @type String
 591		 */
 592		 
 593		/**
 594		 * @attribute expressInstall
 595		 * @description URL pointing to a SWF file that handles Flash Player's express
 596		 *		install feature. Only available in the constructor because it may not be
 597		 *		set after Flash Player has been embedded in the page.
 598		 * @type String
 599		 */
 600
 601		/**
 602		 * @attribute version
 603		 * @description Minimum required version for the SWF file. Only available in the constructor because it may not be
 604		 *		set after Flash Player has been embedded in the page.
 605		 * @type String
 606		 */
 607
 608		/**
 609		 * @attribute backgroundColor
 610		 * @description The background color of the SWF. Only available in the constructor because it may not be
 611		 *		set after Flash Player has been embedded in the page.
 612		 * @type String
 613		 */
 614		 
 615		/**
 616		 * @attribute altText
 617		 * @description The alternative text to provide for screen readers and other assistive technology.
 618		 * @type String
 619		 */
 620		this.getAttributeConfig("altText",
 621		{
 622			method: this._getAltText
 623		});
 624		this.setAttributeConfig("altText",
 625		{
 626			method: this._setAltText
 627		});
 628		
 629		/**
 630		 * @attribute swfURL
 631		 * @description Absolute or relative URL to the SWF displayed by the FlashAdapter. Only available in the constructor because it may not be
 632		 *		set after Flash Player has been embedded in the page.
 633		 * @type String
 634		 */
 635		this.getAttributeConfig("swfURL",
 636		{
 637			method: this._getSWFURL
 638		});
 639	},
 640	
 641	/**
 642	 * Getter for swfURL attribute.
 643	 *
 644	 * @method _getSWFURL
 645	 * @private
 646	 */
 647	_getSWFURL: function()
 648	{
 649		return this._swfURL;
 650	},
 651	
 652	/**
 653	 * Getter for altText attribute.
 654	 *
 655	 * @method _getAltText
 656	 * @private
 657	 */
 658	_getAltText: function()
 659	{
 660		return this._swf.getAltText();
 661	},
 662
 663	/**
 664	 * Setter for altText attribute.
 665	 *
 666	 * @method _setAltText
 667	 * @private
 668	 */
 669	_setAltText: function(value)
 670	{
 671		return this._swf.setAltText(value);
 672	}
 673});
 674
 675/**
 676 * Receives event messages from SWF and passes them to the correct instance
 677 * of FlashAdapter.
 678 *
 679 * @method YAHOO.widget.FlashAdapter.eventHandler
 680 * @static
 681 * @private
 682 */
 683YAHOO.widget.FlashAdapter.eventHandler = function(elementID, event)
 684{
 685	var loadedSWF = YAHOO.util.Dom.get(elementID);
 686	if(!loadedSWF.owner)
 687	{
 688		//fix for ie: if owner doesn't exist yet, try again in a moment
 689		setTimeout(function() { YAHOO.widget.FlashAdapter.eventHandler( elementID, event ); }, 0);
 690	}
 691	else
 692	{
 693		loadedSWF.owner._eventHandler(event);
 694	}
 695};
 696
 697/**
 698 * The number of proxy functions that have been created.
 699 * @static
 700 * @private
 701 */
 702YAHOO.widget.FlashAdapter.proxyFunctionCount = 0;
 703
 704/**
 705 * Creates a globally accessible function that wraps a function reference.
 706 * Returns the proxy function's name as a string for use by the SWF through
 707 * ExternalInterface.
 708 *
 709 * @method YAHOO.widget.FlashAdapter.createProxyFunction
 710 * @static
 711 * @private
 712 */
 713YAHOO.widget.FlashAdapter.createProxyFunction = function(func)
 714{
 715	var index = YAHOO.widget.FlashAdapter.proxyFunctionCount;
 716	YAHOO.widget.FlashAdapter["proxyFunction" + index] = function()
 717	{
 718		return func.apply(null, arguments);
 719	};
 720	YAHOO.widget.FlashAdapter.proxyFunctionCount++;
 721	return "YAHOO.widget.FlashAdapter.proxyFunction" + index.toString();
 722};
 723
 724/**
 725 * Removes a function created with createProxyFunction()
 726 * 
 727 * @method YAHOO.widget.FlashAdapter.removeProxyFunction
 728 * @static
 729 * @private
 730 */
 731YAHOO.widget.FlashAdapter.removeProxyFunction = function(funcName)
 732{
 733	//quick error check
 734	if(!funcName || funcName.indexOf("YAHOO.widget.FlashAdapter.proxyFunction") < 0)
 735	{
 736		return;
 737	}
 738	
 739	funcName = funcName.substr(26);
 740	YAHOO.widget.FlashAdapter[funcName] = null;
 741};
 742
 743/**
 744 * The Charts widget provides a Flash control for displaying data
 745 * graphically by series across A-grade browsers with Flash Player installed.
 746 *
 747 * @module charts
 748 * @requires yahoo, dom, event, datasource
 749 * @title Charts Widget
 750 * @experimental
 751 */
 752 
 753/****************************************************************************/
 754/****************************************************************************/
 755/****************************************************************************/
 756
 757/**
 758 * Chart class for the YUI Charts widget.
 759 *
 760 * @namespace YAHOO.widget
 761 * @class Chart
 762 * @uses YAHOO.widget.FlashAdapter
 763 * @constructor
 764 * @param type {String} The char type. May be "line", "column", "bar", or "pie"
 765 * @param containerId {HTMLElement} Container element for the Flash Player instance.
 766 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
 767 * @param attributes {object} (optional) Object literal of configuration values.
 768 */
 769YAHOO.widget.Chart = function(type, containerId, dataSource, attributes)
 770{
 771	YAHOO.widget.Chart.superclass.constructor.call(this, YAHOO.widget.Chart.SWFURL, containerId, attributes);
 772	
 773	this._type = type;
 774	this._dataSource = dataSource;
 775	
 776	/**
 777	 * Fires when the user moves the mouse over the bounds of an item renderer in the chart.
 778	 *
 779	 * @event itemMouseOverEvent
 780	 * @param event.type {String} The event type
 781	 * @param event.item {Object} The data displayed by the renderer
 782	 * @param event.index {Number} The position within the series that the item appears.
 783	 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
 784	 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
 785	 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
 786	 */
 787	this.createEvent("itemMouseOverEvent");
 788	
 789	/**
 790	 * Fires when the user moves the mouse out of the bounds of an item renderer in the chart.
 791	 *
 792	 * @event itemMouseOutEvent
 793	 * @param event.type {String} The event type
 794	 * @param event.item {Object} The data displayed by the renderer
 795	 * @param event.index {Number} The position within the series that the item appears.
 796	 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
 797	 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
 798	 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
 799	 */
 800	this.createEvent("itemMouseOutEvent");
 801	
 802	/**
 803	 * Fires when the user clicks an item renderer in the chart with the mouse.
 804	 *
 805	 * @event itemClickEvent
 806	 * @param event.type {String} The event type
 807	 * @param event.item {Object} The data displayed by the renderer
 808	 * @param event.index {Number} The position within the series that the item appears.
 809	 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
 810	 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
 811	 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
 812	 */
 813	this.createEvent("itemClickEvent");
 814	
 815	/**
 816	 * Fires when the user double-clicks an item renderer in the chart with the mouse.
 817	 *
 818	 * @event itemDoubleClickEvent
 819	 * @param event.type {String} The event type
 820	 * @param event.item {Object} The data displayed by the renderer
 821	 * @param event.index {Number} The position within the series that the item appears.
 822	 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
 823	 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
 824	 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
 825	 */
 826	this.createEvent("itemDoubleClickEvent");
 827	
 828	/**
 829	 * Fires when the user presses the mouse down on an item to initiate a drag action.
 830	 *
 831	 * @event itemDragStartEvent
 832	 * @param event.type {String} The event type
 833	 * @param event.item {Object} The data displayed by the renderer
 834	 * @param event.index {Number} The position within the series that the item appears.
 835	 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
 836	 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
 837	 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
 838	 */
 839	this.createEvent("itemDragStartEvent");
 840	
 841	/**
 842	 * Fires when the user moves the mouse during a drag action.
 843	 *
 844	 * @event itemDragEvent
 845	 * @param event.type {String} The event type
 846	 * @param event.item {Object} The data displayed by the renderer
 847	 * @param event.index {Number} The position within the series that the item appears.
 848	 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
 849	 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
 850	 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
 851	 */
 852	this.createEvent("itemDragEvent");
 853
 854	/**
 855	 * Fires when the user releases the mouse during a drag action.
 856	 *
 857	 * @event itemDragEndEvent
 858	 * @param event.type {String} The event type
 859	 * @param event.item {Object} The data displayed by the renderer
 860	 * @param event.index {Number} The position within the series that the item appears.
 861	 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
 862	 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
 863	 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
 864	 */
 865	this.createEvent("itemDragEndEvent");
 866};
 867
 868YAHOO.extend(YAHOO.widget.Chart, YAHOO.widget.FlashAdapter,
 869{
 870	/**
 871	 * The type of this chart instance.
 872	 * @property _type
 873	 * @type String
 874	 * @private
 875	 */
 876	_type: null,
 877
 878	/**
 879	 * The id returned from the DataSource's setInterval function.
 880	 * @property _pollingID
 881	 * @type Number
 882	 * @private
 883	 */
 884	_pollingID: null,
 885
 886	/**
 887	 * The time, in ms, between requests for data.
 888	 * @property _pollingInterval
 889	 * @type Number
 890	 * @private
 891	 */
 892	_pollingInterval: null,
 893
 894	/**
 895	 * Stores a reference to the dataTipFunction created by
 896	 * YAHOO.widget.FlashAdapter.createProxyFunction()
 897	 * @property _dataTipFunction
 898	 * @type String
 899	 * @private
 900	 */
 901	_dataTipFunction: null,
 902	
 903	/**
 904	 * Stores references to series labelFunction values created by
 905	 * YAHOO.widget.FlashAdapter.createProxyFunction()
 906	 * @property _seriesLabelFunctions
 907	 * @type Array
 908	 * @private
 909	 */
 910	_seriesLabelFunctions: null,
 911
 912	/**
 913	 * Public accessor to the unique name of the Chart instance.
 914	 *
 915	 * @method toString
 916	 * @return {String} Unique name of the Chart instance.
 917	 */
 918	toString: function()
 919	{
 920		return "Chart " + this._id;
 921	},
 922	
 923	/**
 924	 * Sets a single style value on the Chart instance.
 925	 *
 926	 * @method setStyle
 927	 * @param name {String} Name of the Chart style value to change.
 928	 * @param value {Object} New value to pass to the Chart style.
 929	 */
 930	setStyle: function(name, value)
 931	{
 932		//we must jsonify this because Flash Player versions below 9.0.60 don't handle
 933		//complex ExternalInterface parsing correctly
 934		value = YAHOO.lang.JSON.stringify(value);
 935		this._swf.setStyle(name, value);
 936	},
 937	
 938	/**
 939	 * Resets all styles on the Chart instance.
 940	 *
 941	 * @method setStyles
 942	 * @param styles {Object} Initializer for all Chart styles.
 943	 */
 944	setStyles: function(styles)
 945	{
 946		//we must jsonify this because Flash Player versions below 9.0.60 don't handle
 947		//complex ExternalInterface parsing correctly
 948		styles = YAHOO.lang.JSON.stringify(styles);
 949		this._swf.setStyles(styles);
 950	},
 951	
 952	/**
 953	 * Sets the styles on all series in the Chart.
 954	 *
 955	 * @method setSeriesStyles
 956	 * @param styles {Array} Initializer for all Chart series styles.
 957	 */
 958	setSeriesStyles: function(styles)
 959	{
 960		//we must jsonify this because Flash Player versions below 9.0.60 don't handle
 961		//complex ExternalInterface parsing correctly
 962		for(var i = 0; i < styles.length; i++)
 963		{
 964			styles[i] = YAHOO.lang.JSON.stringify(styles[i]);	
 965		}
 966		this._swf.setSeriesStyles(styles);
 967	},
 968	
 969	destroy: function()
 970	{
 971		//stop polling if needed
 972		if(this._dataSource !== null)
 973		{
 974			if(this._pollingID !== null)
 975			{
 976				this._dataSource.clearInterval(this._pollingID);
 977				this._pollingID = null;
 978			}
 979		}
 980		
 981		//remove proxy functions
 982		if(this._dataTipFunction)
 983		{
 984			YAHOO.widget.FlashAdapter.removeProxyFunction(this._dataTipFunction);
 985		}
 986		
 987		//call last
 988		YAHOO.widget.Chart.superclass.destroy.call(this);
 989	},
 990	
 991	/**
 992	 * Initializes the attributes.
 993	 *
 994	 * @method _initAttributes
 995	 * @private
 996	 */
 997	_initAttributes: function(attributes)
 998	{
 999		YAHOO.widget.Chart.superclass._initAttributes.call(this, attributes);
1000
1001		/**
1002		 * @attribute request
1003		 * @description Request to be sent to the Chart's DataSource.
1004		 * @type String
1005		 */
1006		this.getAttributeConfig("request",
1007		{
1008			method: this._getRequest
1009		});
1010		
1011		this.setAttributeConfig("request",
1012		{
1013			method: this._setRequest
1014		});
1015		
1016		/**
1017		 * @attribute dataSource
1018		 * @description The DataSource instance to display in the Chart.
1019		 * @type DataSource
1020		 */
1021		this.getAttributeConfig("dataSource",
1022		{
1023			method: this._getDataSource
1024		});
1025		
1026		this.setAttributeConfig("dataSource",
1027		{
1028			method: this._setDataSource
1029		});
1030		
1031		/**
1032		 * @attribute series
1033		 * @description Defines the series to be displayed by the Chart.
1034		 * @type Array
1035		 */
1036		this.getAttributeConfig("series",
1037		{
1038			method: this._getSeriesDefs
1039		});
1040		
1041		this.setAttributeConfig("series",
1042		{
1043			method: this._setSeriesDefs
1044		});
1045		
1046		/**
1047		 * @attribute categoryNames
1048		 * @description Defines the names of the categories to be displayed in the Chart..
1049		 * @type Array
1050		 */
1051		this.getAttributeConfig("categoryNames",
1052		{
1053			method: this._getCategoryNames
1054		});
1055		
1056		this.setAttributeConfig("categoryNames",
1057		{
1058			validator: YAHOO.lang.isArray,
1059			method: this._setCategoryNames
1060		});
1061		
1062		/**
1063		 * @attribute dataTipFunction
1064		 * @description The string representation of a globally-accessible function
1065		 * that may be called by the SWF to generate the datatip text for a Chart's item.
1066		 * @type String
1067		 */
1068		this.getAttributeConfig("dataTipFunction",
1069		{
1070			method: this._getDataTipFunction
1071		});
1072		
1073		this.setAttributeConfig("dataTipFunction",
1074		{
1075			method: this._setDataTipFunction
1076		});
1077
1078		/**
1079		 * @attribute polling
1080		 * @description A numeric value indicating the number of milliseconds between
1081		 * polling requests to the DataSource.
1082		 * @type Number
1083		 */
1084		this.getAttributeConfig("polling",
1085		{
1086			method: this._getPolling
1087		});
1088
1089		this.setAttributeConfig("polling",
1090		{
1091			method: this._setPolling
1092		});
1093	},
1094	
1095	/**
1096	 * Called when the SWF is ready for communication. Sets the type, initializes
1097	 * the styles, and sets the DataSource.
1098	 *
1099	 * @method _loadHandler
1100	 * @private
1101	 */
1102	_loadHandler: function()
1103	{
1104		//the type is set separately because it must be first!
1105		this._swf.setType(this._type);
1106		
1107		//set initial styles
1108		if(this._attributes.style)
1109		{
1110			var style = this._attributes.style;
1111			this.setStyles(style);		
1112		}
1113		
1114		YAHOO.widget.Chart.superclass._loadHandler.call(this);
1115		
1116		if(this._dataSource)
1117		{
1118			this.set("dataSource", this._dataSource);
1119		}
1120	},
1121
1122	/**
1123	 * Sends (or resends) the request to the DataSource.
1124	 *
1125	 * @method refreshData
1126	 */
1127	refreshData: function()
1128	{
1129		if(!this._initialized)
1130		{
1131			return;
1132		}
1133		
1134		if(this._dataSource !== null)
1135		{
1136			if(this._pollingID !== null)
1137			{
1138				this._dataSource.clearInterval(this._pollingID);
1139				this._pollingID = null;
1140			}
1141			
1142			if(this._pollingInterval > 0)
1143			{
1144				this._pollingID = this._dataSource.setInterval(this._pollingInterval, this._request, this._loadDataHandler, this);
1145			}
1146			this._dataSource.sendRequest(this._request, this._loadDataHandler, this);
1147		}
1148	},
1149
1150	/**
1151	 * Called when the DataSource receives new data. The series definitions are used
1152	 * to build a data provider for the SWF chart.
1153	 *
1154	 * @method _loadDataHandler
1155	 * @private
1156	 */
1157	_loadDataHandler: function(request, response, error)
1158	{
1159		if(this._swf)
1160		{
1161			if(error)
1162			{
1163				YAHOO.log("Unable to load data.", "error");
1164			}
1165			else
1166			{
1167				var i;
1168				if(this._seriesLabelFunctions)
1169				{
1170					var count = this._seriesLabelFunctions.length;
1171					for(i = 0; i < count; i++)
1172					{
1173						YAHOO.widget.FlashAdapter.removeProxyFunction(this._seriesLabelFunctions[i]);
1174					}
1175					this._seriesLabelFunction = null;
1176				}
1177				this._seriesLabelFunctions = [];
1178
1179				//make a copy of the series definitions so that we aren't
1180				//editing them directly.
1181				var dataProvider = [];	
1182				var seriesCount = 0;
1183				var currentSeries = null;
1184				if(this._seriesDefs !== null)
1185				{
1186					seriesCount = this._seriesDefs.length;
1187					for(i = 0; i < seriesCount; i++)
1188					{
1189						currentSeries = this._seriesDefs[i];
1190						var clonedSeries = {};
1191						for(var prop in currentSeries)
1192						{
1193							if(YAHOO.lang.hasOwnProperty(currentSeries, prop))
1194							{
1195								if(prop == "style")
1196								{
1197									if(currentSeries.style !== null)
1198									{
1199										clonedSeries.style = YAHOO.lang.JSON.stringify(currentSeries.style);
1200									}
1201								}
1202
1203								else if(prop == "labelFunction")
1204								{
1205									if(currentSeries.labelFunction !== null &&
1206										typeof currentSeries.labelFunction == "function")
1207									{
1208										clonedSeries.labelFunction = YAHOO.widget.FlashAdapter.createProxyFunction(currentSeries.labelFunction);
1209										this._seriesLabelFunctions.push(clonedSeries.labelFunction);
1210									}
1211								}
1212
1213								else
1214								{
1215									clonedSeries[prop] = currentSeries[prop];
1216								}
1217							}
1218						}
1219						dataProvider.push(clonedSeries);
1220					}
1221				}
1222
1223				if(seriesCount > 0)
1224				{
1225					for(i = 0; i < seriesCount; i++)
1226					{
1227						currentSeries = dataProvider[i];
1228						if(!currentSeries.type)
1229						{
1230							currentSeries.type = this._type;
1231						}
1232						currentSeries.dataProvider = response.results;
1233					}
1234				}
1235				else
1236				{
1237					var series = {type: this._type, dataProvider: response.results};
1238					dataProvider.push(series);
1239				}
1240				this._swf.setDataProvider(dataProvider);
1241			}
1242		}
1243	},
1244
1245	/**
1246	 * Storage for the request attribute.
1247	 * 
1248	 * @property _request
1249	 * @private
1250	 */
1251	_request: "",
1252	
1253	/**
1254	 * Getter for the request attribute.
1255	 *
1256	 * @method _getRequest
1257	 * @private
1258	 */
1259	_getRequest: function()
1260	{
1261		return this._request;
1262	},
1263	
1264	/**
1265	 * Setter for the request attribute.
1266	 *
1267	 * @method _setRequest
1268	 * @private
1269	 */
1270	_setRequest: function(value)
1271	{
1272		this._request = value;
1273		this.refreshData();
1274	},
1275
1276	/**
1277	 * Storage for the dataSource attribute.
1278	 * 
1279	 * @property _dataSource
1280	 * @private
1281	 */
1282	_dataSource: null,
1283	
1284	/**
1285	 * Getter for the dataSource attribute.
1286	 *
1287	 * @method _getDataSource
1288	 * @private
1289	 */
1290	_getDataSource: function()
1291	{
1292		return this._dataSource;
1293	},
1294
1295	/**
1296	 * Setter for the dataSource attribute.
1297	 *
1298	 * @method _setDataSource
1299	 * @private
1300	 */
1301	_setDataSource: function(value)
1302	{	
1303		this._dataSource = value;
1304		this.refreshData();
1305	},
1306	
1307	/**
1308	 * Storage for the series attribute.
1309	 * 
1310	 * @property _seriesDefs
1311	 * @private
1312	 */
1313	_seriesDefs: null,
1314	
1315	/**
1316	 * Getter for the series attribute.
1317	 *
1318	 * @method _getSeriesDefs
1319	 * @private
1320	 */
1321	_getSeriesDefs: function()
1322	{
1323		return this._seriesDefs;
1324	},
1325	
1326	/**
1327	 * Setter for the series attribute.
1328	 *
1329	 * @method _setSeriesDefs
1330	 * @private
1331	 */
1332	_setSeriesDefs: function(value)
1333	{
1334		this._seriesDefs = value;
1335		this.refreshData();
1336	},
1337
1338	/**
1339	 * Getter for the categoryNames attribute.
1340	 *
1341	 * @method _getCategoryNames
1342	 * @private
1343	 */
1344	_getCategoryNames: function()
1345	{
1346		this._swf.getCategoryNames();
1347	},
1348
1349	/**
1350	 * Setter for the categoryNames attribute.
1351	 *
1352	 * @method _setCategoryNames
1353	 * @private
1354	 */
1355	_setCategoryNames: function(value)
1356	{
1357		this._swf.setCategoryNames(value);
1358	},
1359	
1360	/**
1361	 * Setter for the dataTipFunction attribute.
1362	 *
1363	 * @method _setDataTipFunction
1364	 * @private
1365	 */
1366	_setDataTipFunction: function(value)
1367	{
1368		if(this._dataTipFunction)
1369		{
1370			YAHOO.widget.FlashAdapter.removeProxyFunction(this._dataTipFunction);
1371		}
1372		
1373		if(value && typeof value == "function")
1374		{
1375			value = YAHOO.widget.FlashAdapter.createProxyFunction(value);
1376			this._dataTipFunction = value;
1377		}
1378		this._swf.setDataTipFunction(value);
1379	},
1380
1381	/**
1382	 * Getter for the polling attribute.
1383	 *
1384	 * @method _getPolling
1385	 * @private
1386	 */
1387	_getPolling: function()
1388	{
1389		return this._pollingInterval;
1390	},
1391
1392	/**
1393	 * Setter for the polling attribute.
1394	 *
1395	 * @method _setPolling
1396	 * @private
1397	 */
1398	_setPolling: function(value)
1399	{
1400		this._pollingInterval = value;
1401		this.refreshData();
1402	}
1403});
1404
1405/**
1406 * Storage for the dataTipFunction attribute.
1407 *
1408 * @property Chart.SWFURL
1409 * @private
1410 * @static
1411 * @final
1412 * @default "assets/charts.swf"
1413 */
1414YAHOO.widget.Chart.SWFURL = "assets/charts.swf";
1415
1416/**
1417 * PieChart class for the YUI Charts widget.
1418 *
1419 * @namespace YAHOO.widget
1420 * @class PieChart
1421 * @uses YAHOO.widget.Chart
1422 * @constructor
1423 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1424 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1425 * @param attributes {object} (optional) Object literal of configuration values.
1426 */
1427YAHOO.widget.PieChart = function(containerId, dataSource, attributes)
1428{
1429	YAHOO.widget.PieChart.superclass.constructor.call(this, "pie", containerId, dataSource, attributes);
1430};
1431
1432YAHOO.lang.extend(YAHOO.widget.PieChart, YAHOO.widget.Chart,
1433{
1434	/**
1435	 * Initializes the attributes.
1436	 *
1437	 * @method _initAttributes
1438	 * @private
1439	 */
1440	_initAttributes: function(attributes)
1441	{	
1442		YAHOO.widget.PieChart.superclass._initAttributes.call(this, attributes);
1443		
1444		/**
1445		 * @attribute dataField
1446		 * @description The field in each item that corresponds to the data value.
1447		 * @type String
1448		 */
1449		this.getAttributeConfig("dataField",
1450		{
1451			method: this._getDataField
1452		});
1453   
1454		this.setAttributeConfig("dataField",
1455		{
1456			validator: YAHOO.lang.isString,
1457			method: this._setDataField
1458		});
1459   
1460		/**
1461		 * @attribute categoryField
1462		 * @description The field in each item that corresponds to the category value.
1463		 * @type String
1464		 */
1465		this.getAttributeConfig("categoryField",
1466		{
1467			method: this._getCategoryField
1468		});
1469   
1470		this.setAttributeConfig("categoryField",
1471		{
1472			validator: YAHOO.lang.isString,
1473			method: this._setCategoryField
1474		});
1475	},
1476
1477	/**
1478	 * Getter for the dataField attribute.
1479	 *
1480	 * @method _getDataField
1481	 * @private
1482	 */
1483	_getDataField: function()
1484	{
1485		return this._swf.getDataField();
1486	},
1487
1488	/**
1489	 * Setter for the dataField attribute.
1490	 *
1491	 * @method _setDataField
1492	 * @private
1493	 */
1494	_setDataField: function(value)
1495	{
1496		this._swf.setDataField(value);
1497	},
1498
1499	/**
1500	 * Getter for the categoryField attribute.
1501	 *
1502	 * @method _getCategoryField
1503	 * @private
1504	 */
1505	_getCategoryField: function()
1506	{
1507		return this._swf.getCategoryField();
1508	},
1509
1510	/**
1511	 * Setter for the categoryField attribute.
1512	 *
1513	 * @method _setCategoryField
1514	 * @private
1515	 */
1516	_setCategoryField: function(value)
1517	{
1518		this._swf.setCategoryField(value);
1519	}
1520});
1521
1522/**
1523 * CartesianChart class for the YUI Charts widget.
1524 *
1525 * @namespace YAHOO.widget
1526 * @class CartesianChart
1527 * @uses YAHOO.widget.Chart
1528 * @constructor
1529 * @param type {String} The char type. May be "line", "column", or "bar"
1530 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1531 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1532 * @param attributes {object} (optional) Object literal of configuration values.
1533 */
1534 YAHOO.widget.CartesianChart = function(type, containerId, dataSource, attributes)
1535{
1536	YAHOO.widget.CartesianChart.superclass.constructor.call(this, type, containerId, dataSource, attributes);
1537};
1538
1539YAHOO.lang.extend(YAHOO.widget.CartesianChart, YAHOO.widget.Chart,
1540{
1541	/**
1542	 * Stores a reference to the xAxis labelFunction created by
1543	 * YAHOO.widget.FlashAdapter.createProxyFunction()
1544	 * @property _xAxisLabelFunction
1545	 * @type String
1546	 * @private
1547	 */
1548	_xAxisLabelFunction: null,
1549	
1550	/**
1551	 * Stores a reference to the yAxis labelFunction created by
1552	 * YAHOO.widget.FlashAdapter.createProxyFunction()
1553	 * @property _yAxisLabelFunction
1554	 * @type String
1555	 * @private
1556	 */
1557	_yAxisLabelFunction: null,
1558	
1559	destroy: function()
1560	{
1561		//remove proxy functions
1562		if(this._xAxisLabelFunction)
1563		{
1564			YAHOO.widget.FlashAdapter.removeProxyFunction(this._xAxisLabelFunction);
1565			this._xAxisLabelFunction = null;
1566		}
1567		
1568		if(this._yAxisLabelFunction)
1569		{
1570			YAHOO.widget.FlashAdapter.removeProxyFunction(this._yAxisLabelFunction);
1571			this._yAxisLabelFunction = null;
1572		}
1573	
1574		//call last
1575		YAHOO.widget.CartesianChart.superclass.destroy.call(this);
1576	},
1577	
1578	/**
1579	 * Initializes the attributes.
1580	 *
1581	 * @method _initAttributes
1582	 * @private
1583	 */
1584	_initAttributes: function(attributes)
1585	{	
1586		YAHOO.widget.CartesianChart.superclass._initAttributes.call(this, attributes);
1587
1588		/**
1589		 * @attribute xField
1590		 * @description The field in each item that corresponds to a value on the x axis.
1591		 * @type String
1592		 */
1593		this.getAttributeConfig("xField",
1594		{
1595			method: this._getXField
1596		});
1597
1598		this.setAttributeConfig("xField",
1599		{
1600			validator: YAHOO.lang.isString,
1601			method: this._setXField
1602		});
1603
1604		/**
1605		 * @attribute yField
1606		 * @description The field in each item that corresponds to a value on the x axis.
1607		 * @type String
1608		 */
1609		this.getAttributeConfig("yField",
1610		{
1611			method: this._getYField
1612		});
1613
1614		this.setAttributeConfig("yField",
1615		{
1616			validator: YAHOO.lang.isString,
1617			method: this._setYField
1618		});
1619
1620		/**
1621		 * @attribute xAxis
1622		 * @description A custom configuration for the horizontal x axis.
1623		 * @type Axis
1624		 */
1625		this.setAttributeConfig("xAxis",
1626		{
1627			method: this._setXAxis
1628		});
1629
1630		/**
1631		 * @attribute yAxis
1632		 * @description A custom configuration for the vertical y axis.
1633		 * @type Axis
1634		 */
1635		this.setAttributeConfig("yAxis",
1636		{
1637			method: this._setYAxis
1638		});
1639	},
1640
1641	/**
1642	 * Getter for the xField attribute.
1643	 *
1644	 * @method _getXField
1645	 * @private
1646	 */
1647	_getXField: function()
1648	{
1649		return this._swf.getHorizontalField();
1650	},
1651
1652	/**
1653	 * Setter for the xField attribute.
1654	 *
1655	 * @method _setXField
1656	 * @private
1657	 */
1658	_setXField: function(value)
1659	{
1660		this._swf.setHorizontalField(value);
1661	},
1662
1663	/**
1664	 * Getter for the yField attribute.
1665	 *
1666	 * @method _getYField
1667	 * @private
1668	 */
1669	_getYField: function()
1670	{
1671		return this._swf.getVerticalField();
1672	},
1673
1674	/**
1675	 * Setter for the yField attribute.
1676	 *
1677	 * @method _setYField
1678	 * @private
1679	 */
1680	_setYField: function(value)
1681	{
1682		this._swf.setVerticalField(value);
1683	},
1684	
1685	/**
1686	 * Setter for the xAxis attribute.
1687	 *
1688	 * @method _setXAxis
1689	 * @private
1690	 */
1691	_setXAxis: function(value)
1692	{
1693		if(this._xAxisLabelFunction !== null)
1694		{
1695			YAHOO.widget.FlashAdapter.removeProxyFunction(this._xAxisLabelFunction);
1696			this._xAxisLabelFunction = null;
1697		}
1698		
1699		var clonedXAxis = {};
1700		for(var prop in value)
1701		{
1702			if(prop == "labelFunction")
1703			{
1704				if(value.labelFunction !== null)
1705				{
1706					if(typeof value.labelFunction == "function")
1707					{
1708						clonedXAxis.labelFunction = YAHOO.widget.FlashAdapter.createProxyFunction(value.labelFunction);
1709					}
1710					else
1711					{
1712						clonedXAxis.labelFunction = value.labelFunction;
1713					}
1714					this._xAxisLabelFunction = clonedXAxis.labelFunction;
1715				}
1716			}
1717			else
1718			{
1719				clonedXAxis[prop] = value[prop];
1720			}
1721		}
1722		this._swf.setHorizontalAxis(clonedXAxis);
1723	},
1724
1725	/**
1726	 * Getter for the yAxis attribute.
1727	 *
1728	 * @method _setYAxis
1729	 * @private
1730	 */
1731	_setYAxis: function(value)
1732	{
1733		if(this._yAxisLabelFunction !== null)
1734		{
1735			YAHOO.widget.FlashAdapter.removeProxyFunction(this._yAxisLabelFunction);
1736			this._yAxisLabelFunction = null;
1737		}
1738
1739		var clonedYAxis = {};
1740		for(var prop in value)
1741		{
1742			if(prop == "labelFunction")
1743			{
1744				if(value.labelFunction !== null)
1745				{
1746					if(typeof value.labelFunction == "function")
1747					{
1748						clonedYAxis.labelFunction = YAHOO.widget.FlashAdapter.createProxyFunction(value.labelFunction);
1749					}
1750					else
1751					{
1752						clonedYAxis.labelFunction = value.labelFunction;
1753					}
1754					this._yAxisLabelFunction = clonedYAxis.labelFunction;
1755				}
1756			}
1757			else
1758			{
1759				clonedYAxis[prop] = value[prop];
1760			}
1761		}
1762		this._swf.setVerticalAxis(clonedYAxis);
1763	}
1764});
1765
1766/**
1767 * LineChart class for the YUI Charts widget.
1768 *
1769 * @namespace YAHOO.widget
1770 * @class LineChart
1771 * @uses YAHOO.widget.CartesianChart
1772 * @constructor
1773 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1774 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1775 * @param attributes {object} (optional) Object literal of configuration values.
1776 */
1777YAHOO.widget.LineChart = function(containerId, dataSource, attributes)
1778{
1779	YAHOO.widget.LineChart.superclass.constructor.call(this, "line", containerId, dataSource, attributes);
1780};
1781
1782YAHOO.lang.extend(YAHOO.widget.LineChart, YAHOO.widget.CartesianChart);
1783
1784/**
1785 * ColumnChart class for the YUI Charts widget.
1786 *
1787 * @namespace YAHOO.widget
1788 * @class ColumnChart
1789 * @uses YAHOO.widget.CartesianChart
1790 * @constructor
1791 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1792 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1793 * @param attributes {object} (optional) Object literal of configuration values.
1794 */
1795YAHOO.widget.ColumnChart = function(containerId, dataSource, attributes)
1796{
1797	YAHOO.widget.ColumnChart.superclass.constructor.call(this, "column", containerId, dataSource, attributes);
1798};
1799
1800YAHOO.lang.extend(YAHOO.widget.ColumnChart, YAHOO.widget.CartesianChart);
1801
1802/**
1803 * BarChart class for the YUI Charts widget.
1804 *
1805 * @namespace YAHOO.widget
1806 * @class BarChart
1807 * @uses YAHOO.widget.CartesianChart
1808 * @constructor
1809 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1810 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1811 * @param attributes {object} (optional) Object literal of configuration values.
1812 */
1813YAHOO.widget.BarChart = function(containerId, dataSource, attributes)
1814{
1815	YAHOO.widget.BarChart.superclass.constructor.call(this, "bar", containerId, dataSource, attributes);
1816};
1817
1818YAHOO.lang.extend(YAHOO.widget.BarChart, YAHOO.widget.CartesianChart);
1819
1820/**
1821 * StackedColumnChart class for the YUI Charts widget.
1822 *
1823 * @namespace YAHOO.widget
1824 * @class StackedColumnChart
1825 * @uses YAHOO.widget.CartesianChart
1826 * @constructor
1827 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1828 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1829 * @param attributes {object} (optional) Object literal of configuration values.
1830 */
1831YAHOO.widget.StackedColumnChart = function(containerId, dataSource, attributes)
1832{
1833	YAHOO.widget.StackedColumnChart.superclass.constructor.call(this, "stackcolumn", containerId, dataSource, attributes);
1834};
1835
1836YAHOO.lang.extend(YAHOO.widget.StackedColumnChart, YAHOO.widget.CartesianChart);
1837
1838/**
1839 * StackedBarChart class for the YUI Charts widget.
1840 *
1841 * @namespace YAHOO.widget
1842 * @class StackedBarChart
1843 * @uses YAHOO.widget.CartesianChart
1844 * @constructor
1845 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1846 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1847 * @param attributes {object} (optional) Object literal of configuration values.
1848 */
1849YAHOO.widget.StackedBarChart = function(containerId, dataSource, attributes)
1850{
1851	YAHOO.widget.StackedBarChart.superclass.constructor.call(this, "stackbar", containerId, dataSource, attributes);
1852};
1853
1854YAHOO.lang.extend(YAHOO.widget.StackedBarChart, YAHOO.widget.CartesianChart);
1855
1856/**
1857 * Defines a CartesianChart's vertical or horizontal axis.
1858 *
1859 * @namespace YAHOO.widget
1860 * @class Axis
1861 * @constructor
1862 */
1863YAHOO.widget.Axis = function()
1864{
1865};
1866
1867YAHOO.widget.Axis.prototype = 
1868{
1869	/**
1870	 * The type of axis.
1871	 *
1872	 * @property type
1873	 * @type String
1874	 */
1875	type: null,
1876	
1877	/**
1878	 * If true, the items on the axis will be drawn in opposite direction.
1879	 *
1880	 * @property reverse
1881	 * @type Boolean
1882	 */
1883	reverse: false,
1884	
1885	/**
1886	 * A string reference to the globally-accessible function that may be called to
1887	 * determine each of the label values for this axis. Also accepts function references.
1888	 *
1889	 * @property labelFunction
1890	 * @type String
1891	 */
1892	labelFunction: null,
1893	
1894	/**
1895	 * The space, in pixels, between labels on an axis.
1896	 *
1897	 * @property labelSpacing
1898	 * @type Number
1899	 */
1900	labelSpacing: 2,
1901	
1902	/**
1903	 * The text that will appear next to the axis to indicate information about the data that it displays.
1904	 *
1905	 * @property title
1906	 * @type String
1907	 */
1908	title: null 
1909};
1910
1911/**
1912 * A type of axis whose units are measured in numeric values.
1913 *
1914 * @namespace YAHOO.widget
1915 * @class NumericAxis
1916 * @extends YAHOO.widget.Axis
1917 * @constructor
1918 */
1919YAHOO.widget.NumericAxis = function()
1920{
1921	YAHOO.widget.NumericAxis.superclass.constructor.call(this);
1922};
1923
1924YAHOO.lang.extend(YAHOO.widget.NumericAxis, YAHOO.widget.Axis,
1925{
1926	type: "numeric",
1927	
1928	/**
1929	 * The minimum value drawn by the axis. If not set explicitly, the axis minimum
1930	 * will be calculated automatically.
1931	 *
1932	 * @property minimum
1933	 * @type Number
1934	 */
1935	minimum: NaN,
1936	
1937	/**
1938	 * The maximum value drawn by the axis. If not set explicitly, the axis maximum
1939	 * will be calculated automatically.
1940	 *
1941	 * @property maximum
1942	 * @type Number
1943	 */
1944	maximum: NaN,
1945	
1946	/**
1947	 * The spacing between major intervals on this axis.
1948	 *
1949	 * @property majorUnit
1950	 * @type Number
1951	 */
1952	majorUnit: NaN,
1953
1954	/**
1955	 * The spacing between minor intervals on this axis.
1956	 *
1957	 * @property minorUnit
1958	 * @type Number
1959	 */
1960	minorUnit: NaN,
1961	
1962	/**
1963	 * If true, the labels, ticks, gridlines, and other objects will snap to
1964	 * the nearest major or minor unit. If false, their position will be based
1965	 * on the minimum value.
1966	 *
1967	 * @property snapToUnits
1968	 * @type Boolean
1969	 */
1970	snapToUnits: true,
1971	
1972	/**
1973	 * Series that are stackable will only stack when this value is set to true.
1974	 *
1975	 * @property stackingEnabled
1976	 * @type Boolean
1977	 */
1978	stackingEnabled: false,
1979
1980	/**
1981	 * If true, and the bounds are calculated automatically, either the minimum or
1982	 * maximum will be set to zero.
1983	 *
1984	 * @property alwaysShowZero
1985	 * @type Boolean
1986	 */
1987	alwaysShowZero: true,
1988
1989	/**
1990	 * The scaling algorithm to use on this axis. May be "linear" or "logarithmic".
1991	 *
1992	 * @property scale
1993	 * @type String
1994	 */
1995	scale: "linear",
1996	
1997	/**
1998	 * Indicates whether to round the major unit.
1999	 * 
2000	 * @property roundMajorUnit
2001	 * @type Boolean
2002	 */
2003	roundMajorUnit: true 
2004});
2005
2006/**
2007 * A type of axis whose units are measured in time-based value

Large files files are truncated, but you can click here to view the full file