PageRenderTime 61ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

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