PageRenderTime 60ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

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