PageRenderTime 112ms CodeModel.GetById 20ms app.highlight 80ms RepoModel.GetById 1ms app.codeStats 1ms

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

http://hdbc.googlecode.com/
JavaScript | 2322 lines | 1073 code | 220 blank | 1029 comment | 134 complexity | 204d7e8c9ff56a405e026e9c7cf184c8 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	},
 478
 479	/**
 480	 * Embeds the SWF in the page and associates it with this instance.
 481	 *
 482	 * @method _embedSWF
 483	 * @private
 484	 */
 485	_embedSWF: function(swfURL, containerID, swfID, version, backgroundColor, expressInstall, wmode)
 486	{
 487		//standard SWFObject embed
 488		var swfObj = new YAHOO.deconcept.SWFObject(swfURL, swfID, "100%", "100%", version, backgroundColor);
 489
 490		if(expressInstall)
 491		{
 492			swfObj.useExpressInstall(expressInstall);
 493		}
 494
 495		//make sure we can communicate with ExternalInterface
 496		swfObj.addParam("allowScriptAccess", "always");
 497		
 498		if(wmode)
 499		{
 500			swfObj.addParam("wmode", wmode);
 501		}
 502		
 503		//again, a useful ExternalInterface trick
 504		swfObj.addVariable("allowedDomain", document.location.hostname);
 505
 506		//tell the SWF which HTML element it is in
 507		swfObj.addVariable("elementID", swfID);
 508
 509		// set the name of the function to call when the swf has an event
 510		swfObj.addVariable("eventHandler", "YAHOO.widget.FlashAdapter.eventHandler");
 511
 512		var container = YAHOO.util.Dom.get(containerID);
 513		var result = swfObj.write(container);
 514		if(result)
 515		{
 516			this._swf = YAHOO.util.Dom.get(swfID);
 517			//if successful, let's add an owner property to the SWF reference
 518			//this will allow the event handler to communicate with a YAHOO.widget.FlashAdapter
 519			this._swf.owner = this;
 520		}
 521		else
 522		{
 523		}
 524	},
 525
 526	/**
 527	 * Handles or re-dispatches events received from the SWF.
 528	 *
 529	 * @method _eventHandler
 530	 * @private
 531	 */
 532	_eventHandler: function(event)
 533	{
 534		var type = event.type;
 535		switch(type)
 536		{
 537			case "swfReady":
 538   				this._loadHandler();
 539   				this.fireEvent("contentReady");
 540				return;
 541			case "log":
 542				return;
 543		}
 544		
 545		//be sure to return after your case or the event will automatically fire!
 546		this.fireEvent(type, event);
 547	},
 548
 549	/**
 550	 * Called when the SWF has been initialized.
 551	 *
 552	 * @method _loadHandler
 553	 * @private
 554	 */
 555	_loadHandler: function()
 556	{
 557		this._initialized = false;
 558		this._initAttributes(this._attributes);
 559		this.setAttributes(this._attributes, true);
 560		
 561		this._initialized = true;
 562	},
 563	
 564	set: function(name, value)
 565	{
 566		//save all the attributes in case the swf reloads
 567		//so that we can pass them in again
 568		this._attributes[name] = value;
 569		YAHOO.widget.FlashAdapter.superclass.set.call(this, name, value);
 570	},
 571	
 572	/**
 573	 * Initializes the attributes.
 574	 *
 575	 * @method _initAttributes
 576	 * @private
 577	 */
 578	_initAttributes: function(attributes)
 579	{
 580		//should be overridden if other attributes need to be set up
 581
 582		/**
 583		 * @attribute wmode
 584		 * @description Sets the window mode of the Flash Player control. May be
 585		 *		"window", "opaque", or "transparent". Only available in the constructor
 586		 *		because it may not be set after Flash Player has been embedded in the page.
 587		 * @type String
 588		 */
 589		 
 590		/**
 591		 * @attribute expressInstall
 592		 * @description URL pointing to a SWF file that handles Flash Player's express
 593		 *		install feature. Only available in the constructor because it may not be
 594		 *		set after Flash Player has been embedded in the page.
 595		 * @type String
 596		 */
 597
 598		/**
 599		 * @attribute version
 600		 * @description Minimum required version for the SWF file. Only available in the constructor because it may not be
 601		 *		set after Flash Player has been embedded in the page.
 602		 * @type String
 603		 */
 604
 605		/**
 606		 * @attribute backgroundColor
 607		 * @description The background color of the SWF. Only available in the constructor because it may not be
 608		 *		set after Flash Player has been embedded in the page.
 609		 * @type String
 610		 */
 611		 
 612		/**
 613		 * @attribute altText
 614		 * @description The alternative text to provide for screen readers and other assistive technology.
 615		 * @type String
 616		 */
 617		this.getAttributeConfig("altText",
 618		{
 619			method: this._getAltText
 620		});
 621		this.setAttributeConfig("altText",
 622		{
 623			method: this._setAltText
 624		});
 625		
 626		/**
 627		 * @attribute swfURL
 628		 * @description Absolute or relative URL to the SWF displayed by the FlashAdapter. Only available in the constructor because it may not be
 629		 *		set after Flash Player has been embedded in the page.
 630		 * @type String
 631		 */
 632		this.getAttributeConfig("swfURL",
 633		{
 634			method: this._getSWFURL
 635		});
 636	},
 637	
 638	/**
 639	 * Getter for swfURL attribute.
 640	 *
 641	 * @method _getSWFURL
 642	 * @private
 643	 */
 644	_getSWFURL: function()
 645	{
 646		return this._swfURL;
 647	},
 648	
 649	/**
 650	 * Getter for altText attribute.
 651	 *
 652	 * @method _getAltText
 653	 * @private
 654	 */
 655	_getAltText: function()
 656	{
 657		return this._swf.getAltText();
 658	},
 659
 660	/**
 661	 * Setter for altText attribute.
 662	 *
 663	 * @method _setAltText
 664	 * @private
 665	 */
 666	_setAltText: function(value)
 667	{
 668		return this._swf.setAltText(value);
 669	}
 670});
 671
 672/**
 673 * Receives event messages from SWF and passes them to the correct instance
 674 * of FlashAdapter.
 675 *
 676 * @method YAHOO.widget.FlashAdapter.eventHandler
 677 * @static
 678 * @private
 679 */
 680YAHOO.widget.FlashAdapter.eventHandler = function(elementID, event)
 681{
 682	var loadedSWF = YAHOO.util.Dom.get(elementID);
 683	if(!loadedSWF.owner)
 684	{
 685		//fix for ie: if owner doesn't exist yet, try again in a moment
 686		setTimeout(function() { YAHOO.widget.FlashAdapter.eventHandler( elementID, event ); }, 0);
 687	}
 688	else
 689	{
 690		loadedSWF.owner._eventHandler(event);
 691	}
 692};
 693
 694/**
 695 * The number of proxy functions that have been created.
 696 * @static
 697 * @private
 698 */
 699YAHOO.widget.FlashAdapter.proxyFunctionCount = 0;
 700
 701/**
 702 * Creates a globally accessible function that wraps a function reference.
 703 * Returns the proxy function's name as a string for use by the SWF through
 704 * ExternalInterface.
 705 *
 706 * @method YAHOO.widget.FlashAdapter.createProxyFunction
 707 * @static
 708 * @private
 709 */
 710YAHOO.widget.FlashAdapter.createProxyFunction = function(func)
 711{
 712	var index = YAHOO.widget.FlashAdapter.proxyFunctionCount;
 713	YAHOO.widget.FlashAdapter["proxyFunction" + index] = function()
 714	{
 715		return func.apply(null, arguments);
 716	};
 717	YAHOO.widget.FlashAdapter.proxyFunctionCount++;
 718	return "YAHOO.widget.FlashAdapter.proxyFunction" + index.toString();
 719};
 720
 721/**
 722 * Removes a function created with createProxyFunction()
 723 * 
 724 * @method YAHOO.widget.FlashAdapter.removeProxyFunction
 725 * @static
 726 * @private
 727 */
 728YAHOO.widget.FlashAdapter.removeProxyFunction = function(funcName)
 729{
 730	//quick error check
 731	if(!funcName || funcName.indexOf("YAHOO.widget.FlashAdapter.proxyFunction") < 0)
 732	{
 733		return;
 734	}
 735	
 736	funcName = funcName.substr(26);
 737	YAHOO.widget.FlashAdapter[funcName] = null;
 738};
 739
 740/**
 741 * The Charts widget provides a Flash control for displaying data
 742 * graphically by series across A-grade browsers with Flash Player installed.
 743 *
 744 * @module charts
 745 * @requires yahoo, dom, event, datasource
 746 * @title Charts Widget
 747 * @experimental
 748 */
 749 
 750/****************************************************************************/
 751/****************************************************************************/
 752/****************************************************************************/
 753
 754/**
 755 * Chart class for the YUI Charts widget.
 756 *
 757 * @namespace YAHOO.widget
 758 * @class Chart
 759 * @uses YAHOO.widget.FlashAdapter
 760 * @constructor
 761 * @param type {String} The char type. May be "line", "column", "bar", or "pie"
 762 * @param containerId {HTMLElement} Container element for the Flash Player instance.
 763 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
 764 * @param attributes {object} (optional) Object literal of configuration values.
 765 */
 766YAHOO.widget.Chart = function(type, containerId, dataSource, attributes)
 767{
 768	YAHOO.widget.Chart.superclass.constructor.call(this, YAHOO.widget.Chart.SWFURL, containerId, attributes);
 769	
 770	this._type = type;
 771	this._dataSource = dataSource;
 772	
 773	/**
 774	 * Fires when the user moves the mouse over the bounds of an item renderer in the chart.
 775	 *
 776	 * @event itemMouseOverEvent
 777	 * @param event.type {String} The event type
 778	 * @param event.item {Object} The data displayed by the renderer
 779	 * @param event.index {Number} The position within the series that the item appears.
 780	 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
 781	 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
 782	 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
 783	 */
 784	this.createEvent("itemMouseOverEvent");
 785	
 786	/**
 787	 * Fires when the user moves the mouse out of the bounds of an item renderer in the chart.
 788	 *
 789	 * @event itemMouseOutEvent
 790	 * @param event.type {String} The event type
 791	 * @param event.item {Object} The data displayed by the renderer
 792	 * @param event.index {Number} The position within the series that the item appears.
 793	 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
 794	 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
 795	 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
 796	 */
 797	this.createEvent("itemMouseOutEvent");
 798	
 799	/**
 800	 * Fires when the user clicks an item renderer in the chart with the mouse.
 801	 *
 802	 * @event itemClickEvent
 803	 * @param event.type {String} The event type
 804	 * @param event.item {Object} The data displayed by the renderer
 805	 * @param event.index {Number} The position within the series that the item appears.
 806	 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
 807	 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
 808	 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
 809	 */
 810	this.createEvent("itemClickEvent");
 811	
 812	/**
 813	 * Fires when the user double-clicks an item renderer in the chart with the mouse.
 814	 *
 815	 * @event itemDoubleClickEvent
 816	 * @param event.type {String} The event type
 817	 * @param event.item {Object} The data displayed by the renderer
 818	 * @param event.index {Number} The position within the series that the item appears.
 819	 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
 820	 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
 821	 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
 822	 */
 823	this.createEvent("itemDoubleClickEvent");
 824	
 825	/**
 826	 * Fires when the user presses the mouse down on an item to initiate a drag action.
 827	 *
 828	 * @event itemDragStartEvent
 829	 * @param event.type {String} The event type
 830	 * @param event.item {Object} The data displayed by the renderer
 831	 * @param event.index {Number} The position within the series that the item appears.
 832	 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
 833	 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
 834	 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
 835	 */
 836	this.createEvent("itemDragStartEvent");
 837	
 838	/**
 839	 * Fires when the user moves the mouse during a drag action.
 840	 *
 841	 * @event itemDragEvent
 842	 * @param event.type {String} The event type
 843	 * @param event.item {Object} The data displayed by the renderer
 844	 * @param event.index {Number} The position within the series that the item appears.
 845	 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
 846	 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
 847	 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
 848	 */
 849	this.createEvent("itemDragEvent");
 850
 851	/**
 852	 * Fires when the user releases the mouse during a drag action.
 853	 *
 854	 * @event itemDragEndEvent
 855	 * @param event.type {String} The event type
 856	 * @param event.item {Object} The data displayed by the renderer
 857	 * @param event.index {Number} The position within the series that the item appears.
 858	 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
 859	 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
 860	 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
 861	 */
 862	this.createEvent("itemDragEndEvent");
 863};
 864
 865YAHOO.extend(YAHOO.widget.Chart, YAHOO.widget.FlashAdapter,
 866{
 867	/**
 868	 * The type of this chart instance.
 869	 * @property _type
 870	 * @type String
 871	 * @private
 872	 */
 873	_type: null,
 874
 875	/**
 876	 * The id returned from the DataSource's setInterval function.
 877	 * @property _pollingID
 878	 * @type Number
 879	 * @private
 880	 */
 881	_pollingID: null,
 882
 883	/**
 884	 * The time, in ms, between requests for data.
 885	 * @property _pollingInterval
 886	 * @type Number
 887	 * @private
 888	 */
 889	_pollingInterval: null,
 890
 891	/**
 892	 * Stores a reference to the dataTipFunction created by
 893	 * YAHOO.widget.FlashAdapter.createProxyFunction()
 894	 * @property _dataTipFunction
 895	 * @type String
 896	 * @private
 897	 */
 898	_dataTipFunction: null,
 899	
 900	/**
 901	 * Stores references to series labelFunction values created by
 902	 * YAHOO.widget.FlashAdapter.createProxyFunction()
 903	 * @property _seriesLabelFunctions
 904	 * @type Array
 905	 * @private
 906	 */
 907	_seriesLabelFunctions: null,
 908
 909	/**
 910	 * Public accessor to the unique name of the Chart instance.
 911	 *
 912	 * @method toString
 913	 * @return {String} Unique name of the Chart instance.
 914	 */
 915	toString: function()
 916	{
 917		return "Chart " + this._id;
 918	},
 919	
 920	/**
 921	 * Sets a single style value on the Chart instance.
 922	 *
 923	 * @method setStyle
 924	 * @param name {String} Name of the Chart style value to change.
 925	 * @param value {Object} New value to pass to the Chart style.
 926	 */
 927	setStyle: function(name, value)
 928	{
 929		//we must jsonify this because Flash Player versions below 9.0.60 don't handle
 930		//complex ExternalInterface parsing correctly
 931		value = YAHOO.lang.JSON.stringify(value);
 932		this._swf.setStyle(name, value);
 933	},
 934	
 935	/**
 936	 * Resets all styles on the Chart instance.
 937	 *
 938	 * @method setStyles
 939	 * @param styles {Object} Initializer for all Chart styles.
 940	 */
 941	setStyles: function(styles)
 942	{
 943		//we must jsonify this because Flash Player versions below 9.0.60 don't handle
 944		//complex ExternalInterface parsing correctly
 945		styles = YAHOO.lang.JSON.stringify(styles);
 946		this._swf.setStyles(styles);
 947	},
 948	
 949	/**
 950	 * Sets the styles on all series in the Chart.
 951	 *
 952	 * @method setSeriesStyles
 953	 * @param styles {Array} Initializer for all Chart series styles.
 954	 */
 955	setSeriesStyles: function(styles)
 956	{
 957		//we must jsonify this because Flash Player versions below 9.0.60 don't handle
 958		//complex ExternalInterface parsing correctly
 959		for(var i = 0; i < styles.length; i++)
 960		{
 961			styles[i] = YAHOO.lang.JSON.stringify(styles[i]);	
 962		}
 963		this._swf.setSeriesStyles(styles);
 964	},
 965	
 966	destroy: function()
 967	{
 968		//stop polling if needed
 969		if(this._dataSource !== null)
 970		{
 971			if(this._pollingID !== null)
 972			{
 973				this._dataSource.clearInterval(this._pollingID);
 974				this._pollingID = null;
 975			}
 976		}
 977		
 978		//remove proxy functions
 979		if(this._dataTipFunction)
 980		{
 981			YAHOO.widget.FlashAdapter.removeProxyFunction(this._dataTipFunction);
 982		}
 983		
 984		//call last
 985		YAHOO.widget.Chart.superclass.destroy.call(this);
 986	},
 987	
 988	/**
 989	 * Initializes the attributes.
 990	 *
 991	 * @method _initAttributes
 992	 * @private
 993	 */
 994	_initAttributes: function(attributes)
 995	{
 996		YAHOO.widget.Chart.superclass._initAttributes.call(this, attributes);
 997
 998		/**
 999		 * @attribute request
1000		 * @description Request to be sent to the Chart's DataSource.
1001		 * @type String
1002		 */
1003		this.getAttributeConfig("request",
1004		{
1005			method: this._getRequest
1006		});
1007		
1008		this.setAttributeConfig("request",
1009		{
1010			method: this._setRequest
1011		});
1012		
1013		/**
1014		 * @attribute dataSource
1015		 * @description The DataSource instance to display in the Chart.
1016		 * @type DataSource
1017		 */
1018		this.getAttributeConfig("dataSource",
1019		{
1020			method: this._getDataSource
1021		});
1022		
1023		this.setAttributeConfig("dataSource",
1024		{
1025			method: this._setDataSource
1026		});
1027		
1028		/**
1029		 * @attribute series
1030		 * @description Defines the series to be displayed by the Chart.
1031		 * @type Array
1032		 */
1033		this.getAttributeConfig("series",
1034		{
1035			method: this._getSeriesDefs
1036		});
1037		
1038		this.setAttributeConfig("series",
1039		{
1040			method: this._setSeriesDefs
1041		});
1042		
1043		/**
1044		 * @attribute categoryNames
1045		 * @description Defines the names of the categories to be displayed in the Chart..
1046		 * @type Array
1047		 */
1048		this.getAttributeConfig("categoryNames",
1049		{
1050			method: this._getCategoryNames
1051		});
1052		
1053		this.setAttributeConfig("categoryNames",
1054		{
1055			validator: YAHOO.lang.isArray,
1056			method: this._setCategoryNames
1057		});
1058		
1059		/**
1060		 * @attribute dataTipFunction
1061		 * @description The string representation of a globally-accessible function
1062		 * that may be called by the SWF to generate the datatip text for a Chart's item.
1063		 * @type String
1064		 */
1065		this.getAttributeConfig("dataTipFunction",
1066		{
1067			method: this._getDataTipFunction
1068		});
1069		
1070		this.setAttributeConfig("dataTipFunction",
1071		{
1072			method: this._setDataTipFunction
1073		});
1074
1075		/**
1076		 * @attribute polling
1077		 * @description A numeric value indicating the number of milliseconds between
1078		 * polling requests to the DataSource.
1079		 * @type Number
1080		 */
1081		this.getAttributeConfig("polling",
1082		{
1083			method: this._getPolling
1084		});
1085
1086		this.setAttributeConfig("polling",
1087		{
1088			method: this._setPolling
1089		});
1090	},
1091	
1092	/**
1093	 * Called when the SWF is ready for communication. Sets the type, initializes
1094	 * the styles, and sets the DataSource.
1095	 *
1096	 * @method _loadHandler
1097	 * @private
1098	 */
1099	_loadHandler: function()
1100	{
1101		//the type is set separately because it must be first!
1102		this._swf.setType(this._type);
1103		
1104		//set initial styles
1105		if(this._attributes.style)
1106		{
1107			var style = this._attributes.style;
1108			this.setStyles(style);		
1109		}
1110		
1111		YAHOO.widget.Chart.superclass._loadHandler.call(this);
1112		
1113		if(this._dataSource)
1114		{
1115			this.set("dataSource", this._dataSource);
1116		}
1117	},
1118
1119	/**
1120	 * Sends (or resends) the request to the DataSource.
1121	 *
1122	 * @method refreshData
1123	 */
1124	refreshData: function()
1125	{
1126		if(!this._initialized)
1127		{
1128			return;
1129		}
1130		
1131		if(this._dataSource !== null)
1132		{
1133			if(this._pollingID !== null)
1134			{
1135				this._dataSource.clearInterval(this._pollingID);
1136				this._pollingID = null;
1137			}
1138			
1139			if(this._pollingInterval > 0)
1140			{
1141				this._pollingID = this._dataSource.setInterval(this._pollingInterval, this._request, this._loadDataHandler, this);
1142			}
1143			this._dataSource.sendRequest(this._request, this._loadDataHandler, this);
1144		}
1145	},
1146
1147	/**
1148	 * Called when the DataSource receives new data. The series definitions are used
1149	 * to build a data provider for the SWF chart.
1150	 *
1151	 * @method _loadDataHandler
1152	 * @private
1153	 */
1154	_loadDataHandler: function(request, response, error)
1155	{
1156		if(this._swf)
1157		{
1158			if(error)
1159			{
1160			}
1161			else
1162			{
1163				var i;
1164				if(this._seriesLabelFunctions)
1165				{
1166					var count = this._seriesLabelFunctions.length;
1167					for(i = 0; i < count; i++)
1168					{
1169						YAHOO.widget.FlashAdapter.removeProxyFunction(this._seriesLabelFunctions[i]);
1170					}
1171					this._seriesLabelFunction = null;
1172				}
1173				this._seriesLabelFunctions = [];
1174
1175				//make a copy of the series definitions so that we aren't
1176				//editing them directly.
1177				var dataProvider = [];	
1178				var seriesCount = 0;
1179				var currentSeries = null;
1180				if(this._seriesDefs !== null)
1181				{
1182					seriesCount = this._seriesDefs.length;
1183					for(i = 0; i < seriesCount; i++)
1184					{
1185						currentSeries = this._seriesDefs[i];
1186						var clonedSeries = {};
1187						for(var prop in currentSeries)
1188						{
1189							if(YAHOO.lang.hasOwnProperty(currentSeries, prop))
1190							{
1191								if(prop == "style")
1192								{
1193									if(currentSeries.style !== null)
1194									{
1195										clonedSeries.style = YAHOO.lang.JSON.stringify(currentSeries.style);
1196									}
1197								}
1198
1199								else if(prop == "labelFunction")
1200								{
1201									if(currentSeries.labelFunction !== null &&
1202										typeof currentSeries.labelFunction == "function")
1203									{
1204										clonedSeries.labelFunction = YAHOO.widget.FlashAdapter.createProxyFunction(currentSeries.labelFunction);
1205										this._seriesLabelFunctions.push(clonedSeries.labelFunction);
1206									}
1207								}
1208
1209								else
1210								{
1211									clonedSeries[prop] = currentSeries[prop];
1212								}
1213							}
1214						}
1215						dataProvider.push(clonedSeries);
1216					}
1217				}
1218
1219				if(seriesCount > 0)
1220				{
1221					for(i = 0; i < seriesCount; i++)
1222					{
1223						currentSeries = dataProvider[i];
1224						if(!currentSeries.type)
1225						{
1226							currentSeries.type = this._type;
1227						}
1228						currentSeries.dataProvider = response.results;
1229					}
1230				}
1231				else
1232				{
1233					var series = {type: this._type, dataProvider: response.results};
1234					dataProvider.push(series);
1235				}
1236				this._swf.setDataProvider(dataProvider);
1237			}
1238		}
1239	},
1240
1241	/**
1242	 * Storage for the request attribute.
1243	 * 
1244	 * @property _request
1245	 * @private
1246	 */
1247	_request: "",
1248	
1249	/**
1250	 * Getter for the request attribute.
1251	 *
1252	 * @method _getRequest
1253	 * @private
1254	 */
1255	_getRequest: function()
1256	{
1257		return this._request;
1258	},
1259	
1260	/**
1261	 * Setter for the request attribute.
1262	 *
1263	 * @method _setRequest
1264	 * @private
1265	 */
1266	_setRequest: function(value)
1267	{
1268		this._request = value;
1269		this.refreshData();
1270	},
1271
1272	/**
1273	 * Storage for the dataSource attribute.
1274	 * 
1275	 * @property _dataSource
1276	 * @private
1277	 */
1278	_dataSource: null,
1279	
1280	/**
1281	 * Getter for the dataSource attribute.
1282	 *
1283	 * @method _getDataSource
1284	 * @private
1285	 */
1286	_getDataSource: function()
1287	{
1288		return this._dataSource;
1289	},
1290
1291	/**
1292	 * Setter for the dataSource attribute.
1293	 *
1294	 * @method _setDataSource
1295	 * @private
1296	 */
1297	_setDataSource: function(value)
1298	{	
1299		this._dataSource = value;
1300		this.refreshData();
1301	},
1302	
1303	/**
1304	 * Storage for the series attribute.
1305	 * 
1306	 * @property _seriesDefs
1307	 * @private
1308	 */
1309	_seriesDefs: null,
1310	
1311	/**
1312	 * Getter for the series attribute.
1313	 *
1314	 * @method _getSeriesDefs
1315	 * @private
1316	 */
1317	_getSeriesDefs: function()
1318	{
1319		return this._seriesDefs;
1320	},
1321	
1322	/**
1323	 * Setter for the series attribute.
1324	 *
1325	 * @method _setSeriesDefs
1326	 * @private
1327	 */
1328	_setSeriesDefs: function(value)
1329	{
1330		this._seriesDefs = value;
1331		this.refreshData();
1332	},
1333
1334	/**
1335	 * Getter for the categoryNames attribute.
1336	 *
1337	 * @method _getCategoryNames
1338	 * @private
1339	 */
1340	_getCategoryNames: function()
1341	{
1342		this._swf.getCategoryNames();
1343	},
1344
1345	/**
1346	 * Setter for the categoryNames attribute.
1347	 *
1348	 * @method _setCategoryNames
1349	 * @private
1350	 */
1351	_setCategoryNames: function(value)
1352	{
1353		this._swf.setCategoryNames(value);
1354	},
1355	
1356	/**
1357	 * Setter for the dataTipFunction attribute.
1358	 *
1359	 * @method _setDataTipFunction
1360	 * @private
1361	 */
1362	_setDataTipFunction: function(value)
1363	{
1364		if(this._dataTipFunction)
1365		{
1366			YAHOO.widget.FlashAdapter.removeProxyFunction(this._dataTipFunction);
1367		}
1368		
1369		if(value && typeof value == "function")
1370		{
1371			value = YAHOO.widget.FlashAdapter.createProxyFunction(value);
1372			this._dataTipFunction = value;
1373		}
1374		this._swf.setDataTipFunction(value);
1375	},
1376
1377	/**
1378	 * Getter for the polling attribute.
1379	 *
1380	 * @method _getPolling
1381	 * @private
1382	 */
1383	_getPolling: function()
1384	{
1385		return this._pollingInterval;
1386	},
1387
1388	/**
1389	 * Setter for the polling attribute.
1390	 *
1391	 * @method _setPolling
1392	 * @private
1393	 */
1394	_setPolling: function(value)
1395	{
1396		this._pollingInterval = value;
1397		this.refreshData();
1398	}
1399});
1400
1401/**
1402 * Storage for the dataTipFunction attribute.
1403 *
1404 * @property Chart.SWFURL
1405 * @private
1406 * @static
1407 * @final
1408 * @default "assets/charts.swf"
1409 */
1410YAHOO.widget.Chart.SWFURL = "assets/charts.swf";
1411
1412/**
1413 * PieChart class for the YUI Charts widget.
1414 *
1415 * @namespace YAHOO.widget
1416 * @class PieChart
1417 * @uses YAHOO.widget.Chart
1418 * @constructor
1419 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1420 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1421 * @param attributes {object} (optional) Object literal of configuration values.
1422 */
1423YAHOO.widget.PieChart = function(containerId, dataSource, attributes)
1424{
1425	YAHOO.widget.PieChart.superclass.constructor.call(this, "pie", containerId, dataSource, attributes);
1426};
1427
1428YAHOO.lang.extend(YAHOO.widget.PieChart, YAHOO.widget.Chart,
1429{
1430	/**
1431	 * Initializes the attributes.
1432	 *
1433	 * @method _initAttributes
1434	 * @private
1435	 */
1436	_initAttributes: function(attributes)
1437	{	
1438		YAHOO.widget.PieChart.superclass._initAttributes.call(this, attributes);
1439		
1440		/**
1441		 * @attribute dataField
1442		 * @description The field in each item that corresponds to the data value.
1443		 * @type String
1444		 */
1445		this.getAttributeConfig("dataField",
1446		{
1447			method: this._getDataField
1448		});
1449   
1450		this.setAttributeConfig("dataField",
1451		{
1452			validator: YAHOO.lang.isString,
1453			method: this._setDataField
1454		});
1455   
1456		/**
1457		 * @attribute categoryField
1458		 * @description The field in each item that corresponds to the category value.
1459		 * @type String
1460		 */
1461		this.getAttributeConfig("categoryField",
1462		{
1463			method: this._getCategoryField
1464		});
1465   
1466		this.setAttributeConfig("categoryField",
1467		{
1468			validator: YAHOO.lang.isString,
1469			method: this._setCategoryField
1470		});
1471	},
1472
1473	/**
1474	 * Getter for the dataField attribute.
1475	 *
1476	 * @method _getDataField
1477	 * @private
1478	 */
1479	_getDataField: function()
1480	{
1481		return this._swf.getDataField();
1482	},
1483
1484	/**
1485	 * Setter for the dataField attribute.
1486	 *
1487	 * @method _setDataField
1488	 * @private
1489	 */
1490	_setDataField: function(value)
1491	{
1492		this._swf.setDataField(value);
1493	},
1494
1495	/**
1496	 * Getter for the categoryField attribute.
1497	 *
1498	 * @method _getCategoryField
1499	 * @private
1500	 */
1501	_getCategoryField: function()
1502	{
1503		return this._swf.getCategoryField();
1504	},
1505
1506	/**
1507	 * Setter for the categoryField attribute.
1508	 *
1509	 * @method _setCategoryField
1510	 * @private
1511	 */
1512	_setCategoryField: function(value)
1513	{
1514		this._swf.setCategoryField(value);
1515	}
1516});
1517
1518/**
1519 * CartesianChart class for the YUI Charts widget.
1520 *
1521 * @namespace YAHOO.widget
1522 * @class CartesianChart
1523 * @uses YAHOO.widget.Chart
1524 * @constructor
1525 * @param type {String} The char type. May be "line", "column", or "bar"
1526 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1527 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1528 * @param attributes {object} (optional) Object literal of configuration values.
1529 */
1530 YAHOO.widget.CartesianChart = function(type, containerId, dataSource, attributes)
1531{
1532	YAHOO.widget.CartesianChart.superclass.constructor.call(this, type, containerId, dataSource, attributes);
1533};
1534
1535YAHOO.lang.extend(YAHOO.widget.CartesianChart, YAHOO.widget.Chart,
1536{
1537	/**
1538	 * Stores a reference to the xAxis labelFunction created by
1539	 * YAHOO.widget.FlashAdapter.createProxyFunction()
1540	 * @property _xAxisLabelFunction
1541	 * @type String
1542	 * @private
1543	 */
1544	_xAxisLabelFunction: null,
1545	
1546	/**
1547	 * Stores a reference to the yAxis labelFunction created by
1548	 * YAHOO.widget.FlashAdapter.createProxyFunction()
1549	 * @property _yAxisLabelFunction
1550	 * @type String
1551	 * @private
1552	 */
1553	_yAxisLabelFunction: null,
1554	
1555	destroy: function()
1556	{
1557		//remove proxy functions
1558		if(this._xAxisLabelFunction)
1559		{
1560			YAHOO.widget.FlashAdapter.removeProxyFunction(this._xAxisLabelFunction);
1561			this._xAxisLabelFunction = null;
1562		}
1563		
1564		if(this._yAxisLabelFunction)
1565		{
1566			YAHOO.widget.FlashAdapter.removeProxyFunction(this._yAxisLabelFunction);
1567			this._yAxisLabelFunction = null;
1568		}
1569	
1570		//call last
1571		YAHOO.widget.CartesianChart.superclass.destroy.call(this);
1572	},
1573	
1574	/**
1575	 * Initializes the attributes.
1576	 *
1577	 * @method _initAttributes
1578	 * @private
1579	 */
1580	_initAttributes: function(attributes)
1581	{	
1582		YAHOO.widget.CartesianChart.superclass._initAttributes.call(this, attributes);
1583
1584		/**
1585		 * @attribute xField
1586		 * @description The field in each item that corresponds to a value on the x axis.
1587		 * @type String
1588		 */
1589		this.getAttributeConfig("xField",
1590		{
1591			method: this._getXField
1592		});
1593
1594		this.setAttributeConfig("xField",
1595		{
1596			validator: YAHOO.lang.isString,
1597			method: this._setXField
1598		});
1599
1600		/**
1601		 * @attribute yField
1602		 * @description The field in each item that corresponds to a value on the x axis.
1603		 * @type String
1604		 */
1605		this.getAttributeConfig("yField",
1606		{
1607			method: this._getYField
1608		});
1609
1610		this.setAttributeConfig("yField",
1611		{
1612			validator: YAHOO.lang.isString,
1613			method: this._setYField
1614		});
1615
1616		/**
1617		 * @attribute xAxis
1618		 * @description A custom configuration for the horizontal x axis.
1619		 * @type Axis
1620		 */
1621		this.setAttributeConfig("xAxis",
1622		{
1623			method: this._setXAxis
1624		});
1625
1626		/**
1627		 * @attribute yAxis
1628		 * @description A custom configuration for the vertical y axis.
1629		 * @type Axis
1630		 */
1631		this.setAttributeConfig("yAxis",
1632		{
1633			method: this._setYAxis
1634		});
1635	},
1636
1637	/**
1638	 * Getter for the xField attribute.
1639	 *
1640	 * @method _getXField
1641	 * @private
1642	 */
1643	_getXField: function()
1644	{
1645		return this._swf.getHorizontalField();
1646	},
1647
1648	/**
1649	 * Setter for the xField attribute.
1650	 *
1651	 * @method _setXField
1652	 * @private
1653	 */
1654	_setXField: function(value)
1655	{
1656		this._swf.setHorizontalField(value);
1657	},
1658
1659	/**
1660	 * Getter for the yField attribute.
1661	 *
1662	 * @method _getYField
1663	 * @private
1664	 */
1665	_getYField: function()
1666	{
1667		return this._swf.getVerticalField();
1668	},
1669
1670	/**
1671	 * Setter for the yField attribute.
1672	 *
1673	 * @method _setYField
1674	 * @private
1675	 */
1676	_setYField: function(value)
1677	{
1678		this._swf.setVerticalField(value);
1679	},
1680	
1681	/**
1682	 * Setter for the xAxis attribute.
1683	 *
1684	 * @method _setXAxis
1685	 * @private
1686	 */
1687	_setXAxis: function(value)
1688	{
1689		if(this._xAxisLabelFunction !== null)
1690		{
1691			YAHOO.widget.FlashAdapter.removeProxyFunction(this._xAxisLabelFunction);
1692			this._xAxisLabelFunction = null;
1693		}
1694		
1695		var clonedXAxis = {};
1696		for(var prop in value)
1697		{
1698			if(prop == "labelFunction")
1699			{
1700				if(value.labelFunction !== null)
1701				{
1702					if(typeof value.labelFunction == "function")
1703					{
1704						clonedXAxis.labelFunction = YAHOO.widget.FlashAdapter.createProxyFunction(value.labelFunction);
1705					}
1706					else
1707					{
1708						clonedXAxis.labelFunction = value.labelFunction;
1709					}
1710					this._xAxisLabelFunction = clonedXAxis.labelFunction;
1711				}
1712			}
1713			else
1714			{
1715				clonedXAxis[prop] = value[prop];
1716			}
1717		}
1718		this._swf.setHorizontalAxis(clonedXAxis);
1719	},
1720
1721	/**
1722	 * Getter for the yAxis attribute.
1723	 *
1724	 * @method _setYAxis
1725	 * @private
1726	 */
1727	_setYAxis: function(value)
1728	{
1729		if(this._yAxisLabelFunction !== null)
1730		{
1731			YAHOO.widget.FlashAdapter.removeProxyFunction(this._yAxisLabelFunction);
1732			this._yAxisLabelFunction = null;
1733		}
1734
1735		var clonedYAxis = {};
1736		for(var prop in value)
1737		{
1738			if(prop == "labelFunction")
1739			{
1740				if(value.labelFunction !== null)
1741				{
1742					if(typeof value.labelFunction == "function")
1743					{
1744						clonedYAxis.labelFunction = YAHOO.widget.FlashAdapter.createProxyFunction(value.labelFunction);
1745					}
1746					else
1747					{
1748						clonedYAxis.labelFunction = value.labelFunction;
1749					}
1750					this._yAxisLabelFunction = clonedYAxis.labelFunction;
1751				}
1752			}
1753			else
1754			{
1755				clonedYAxis[prop] = value[prop];
1756			}
1757		}
1758		this._swf.setVerticalAxis(clonedYAxis);
1759	}
1760});
1761
1762/**
1763 * LineChart class for the YUI Charts widget.
1764 *
1765 * @namespace YAHOO.widget
1766 * @class LineChart
1767 * @uses YAHOO.widget.CartesianChart
1768 * @constructor
1769 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1770 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1771 * @param attributes {object} (optional) Object literal of configuration values.
1772 */
1773YAHOO.widget.LineChart = function(containerId, dataSource, attributes)
1774{
1775	YAHOO.widget.LineChart.superclass.constructor.call(this, "line", containerId, dataSource, attributes);
1776};
1777
1778YAHOO.lang.extend(YAHOO.widget.LineChart, YAHOO.widget.CartesianChart);
1779
1780/**
1781 * ColumnChart class for the YUI Charts widget.
1782 *
1783 * @namespace YAHOO.widget
1784 * @class ColumnChart
1785 * @uses YAHOO.widget.CartesianChart
1786 * @constructor
1787 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1788 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1789 * @param attributes {object} (optional) Object literal of configuration values.
1790 */
1791YAHOO.widget.ColumnChart = function(containerId, dataSource, attributes)
1792{
1793	YAHOO.widget.ColumnChart.superclass.constructor.call(this, "column", containerId, dataSource, attributes);
1794};
1795
1796YAHOO.lang.extend(YAHOO.widget.ColumnChart, YAHOO.widget.CartesianChart);
1797
1798/**
1799 * BarChart class for the YUI Charts widget.
1800 *
1801 * @namespace YAHOO.widget
1802 * @class BarChart
1803 * @uses YAHOO.widget.CartesianChart
1804 * @constructor
1805 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1806 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1807 * @param attributes {object} (optional) Object literal of configuration values.
1808 */
1809YAHOO.widget.BarChart = function(containerId, dataSource, attributes)
1810{
1811	YAHOO.widget.BarChart.superclass.constructor.call(this, "bar", containerId, dataSource, attributes);
1812};
1813
1814YAHOO.lang.extend(YAHOO.widget.BarChart, YAHOO.widget.CartesianChart);
1815
1816/**
1817 * StackedColumnChart class for the YUI Charts widget.
1818 *
1819 * @namespace YAHOO.widget
1820 * @class StackedColumnChart
1821 * @uses YAHOO.widget.CartesianChart
1822 * @constructor
1823 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1824 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1825 * @param attributes {object} (optional) Object literal of configuration values.
1826 */
1827YAHOO.widget.StackedColumnChart = function(containerId, dataSource, attributes)
1828{
1829	YAHOO.widget.StackedColumnChart.superclass.constructor.call(this, "stackcolumn", containerId, dataSource, attributes);
1830};
1831
1832YAHOO.lang.extend(YAHOO.widget.StackedColumnChart, YAHOO.widget.CartesianChart);
1833
1834/**
1835 * StackedBarChart class for the YUI Charts widget.
1836 *
1837 * @namespace YAHOO.widget
1838 * @class StackedBarChart
1839 * @uses YAHOO.widget.CartesianChart
1840 * @constructor
1841 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1842 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1843 * @param attributes {object} (optional) Object literal of configuration values.
1844 */
1845YAHOO.widget.StackedBarChart = function(containerId, dataSource, attributes)
1846{
1847	YAHOO.widget.StackedBarChart.superclass.constructor.call(this, "stackbar", containerId, dataSource, attributes);
1848};
1849
1850YAHOO.lang.extend(YAHOO.widget.StackedBarChart, YAHOO.widget.CartesianChart);
1851
1852/**
1853 * Defines a CartesianChart's vertical or horizontal axis.
1854 *
1855 * @namespace YAHOO.widget
1856 * @class Axis
1857 * @constructor
1858 */
1859YAHOO.widget.Axis = function()
1860{
1861};
1862
1863YAHOO.widget.Axis.prototype = 
1864{
1865	/**
1866	 * The type of axis.
1867	 *
1868	 * @property type
1869	 * @type String
1870	 */
1871	type: null,
1872	
1873	/**
1874	 * If true, the items on the axis will be drawn in opposite direction.
1875	 *
1876	 * @property reverse
1877	 * @type Boolean
1878	 */
1879	reverse: false,
1880	
1881	/**
1882	 * A string reference to the globally-accessible function that may be called to
1883	 * determine each of the label values for this axis. Also accepts function references.
1884	 *
1885	 * @property labelFunction
1886	 * @type String
1887	 */
1888	labelFunction: null,
1889	
1890	/**
1891	 * The space, in pixels, between labels on an axis.
1892	 *
1893	 * @property labelSpacing
1894	 * @type Number
1895	 */
1896	labelSpacing: 2,
1897	
1898	/**
1899	 * The text that will appear next to the axis to indicate information about the data that it displays.
1900	 *
1901	 * @property title
1902	 * @type String
1903	 */
1904	title: null 
1905};
1906
1907/**
1908 * A type of axis whose units are measured in numeric values.
1909 *
1910 * @namespace YAHOO.widget
1911 * @class NumericAxis
1912 * @extends YAHOO.widget.Axis
1913 * @constructor
1914 */
1915YAHOO.widget.NumericAxis = function()
1916{
1917	YAHOO.widget.NumericAxis.superclass.constructor.call(this);
1918};
1919
1920YAHOO.lang.extend(YAHOO.widget.NumericAxis, YAHOO.widget.Axis,
1921{
1922	type: "numeric",
1923	
1924	/**
1925	 * The minimum value drawn by the axis. If not set explicitly, the axis minimum
1926	 * will be calculated automatically.
1927	 *
1928	 * @property minimum
1929	 * @type Number
1930	 */
1931	minimum: NaN,
1932	
1933	/**
1934	 * The maximum value drawn by the axis. If not set explicitly, the axis maximum
1935	 * will be calculated automatically.
1936	 *
1937	 * @property maximum
1938	 * @type Number
1939	 */
1940	maximum: NaN,
1941	
1942	/**
1943	 * The spacing between major intervals on this axis.
1944	 *
1945	 * @property majorUnit
1946	 * @type Number
1947	 */
1948	majorUnit: NaN,
1949
1950	/**
1951	 * The spacing between minor intervals on this axis.
1952	 *
1953	 * @property minorUnit
1954	 * @type Number
1955	 */
1956	minorUnit: NaN,
1957	
1958	/**
1959	 * If true, the labels, ticks, gridlines, and other objects will snap to
1960	 * the nearest major or minor unit. If false, their position will be based
1961	 * on the minimum value.
1962	 *
1963	 * @property snapToUnits
1964	 * @type Boolean
1965	 */
1966	snapToUnits: true,
1967	
1968	/**
1969	 * Series that are stackable will only stack when this value is set to true.
1970	 *
1971	 * @property stackingEnabled
1972	 * @type Boolean
1973	 */
1974	stackingEnabled: false,
1975
1976	/**
1977	 * If true, and the bounds are calculated automatically, either the minimum or
1978	 * maximum will be set to zero.
1979	 *
1980	 * @property alwaysShowZero
1981	 * @type Boolean
1982	 */
1983	alwaysShowZero: true,
1984
1985	/**
1986	 * The scaling algorithm to use on this axis. May be "linear" or "logarithmic".
1987	 *
1988	 * @property scale
1989	 * @type String
1990	 */
1991	scale: "linear",
1992	
1993	/**
1994	 * Indicates whether to round the major unit.
1995	 * 
1996	 * @property roundMajorUnit
1997	 * @type Boolean
1998	 */
1999	roundMajorUnit: true 
2000});
2001
2002/**
2003 * A type of axis whose units are measured in time-based values.
2004 *
2005 * @namespace YAHOO.widget
2006 * @class TimeAxis
2007 * @constructor
2008 */
2009YAHOO.widget.TimeAxis = function()
2010{
2011	YAHOO.widget.TimeAxis.superclass.constructor.call(this);
2012};
2013
2014YAHOO.lang.extend(YAHOO.widget.TimeAxis, YAHOO.widg

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