charts-debug.js 56 KB

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