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