2 Copyright (c) 2011, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
8 * The Charts widget provides a Flash control for displaying data
9 * graphically by series across A-grade browsers with Flash Player installed.
12 * @requires yahoo, dom, event, datasource
13 * @title Charts Widget
16 /****************************************************************************/
17 /****************************************************************************/
18 /****************************************************************************/
21 * Chart class for the YUI Charts widget.
23 * @namespace YAHOO.widget
25 * @uses YAHOO.util.AttributeProvider
27 * @param type {String} The char type. May be "line", "column", "bar", or "pie"
28 * @param containerId {HTMLElement} Container element for the Flash Player instance.
29 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
30 * @param attributes {object} (optional) Object literal of configuration values.
32 YAHOO.widget.Chart = function(type, containerId, dataSource, configurationAttributes)
35 this._dataSource = dataSource;
37 var possibleParams = {align:"", allowNetworking:"", allowScriptAccess:"", base:"", bgcolor:"", menu:"", name:"", quality:"", salign:"", scale:"", tabindex:"", wmode:""};
38 var attributes = {fixedAttributes:{allowScriptAccess:"always"}, flashVars:{allowedDomain : document.location.hostname}, backgroundColor:"#ffffff", host:this, version:9.045};
40 for(var i in configurationAttributes)
42 if(possibleParams.hasOwnProperty(i))
44 attributes.fixedAttributes[i] = configurationAttributes[i];
48 attributes[i] = configurationAttributes[i];
52 this._id = attributes.id = attributes.id || YAHOO.util.Dom.generateId(null, "yuigen");
54 this._swfURL = YAHOO.widget.Chart.SWFURL;
55 this._containerID = containerId;
57 this._attributes = attributes;
58 this._swfEmbed = new YAHOO.widget.SWF(containerId, YAHOO.widget.Chart.SWFURL, attributes);
60 this._swf = this._swfEmbed.swf;
61 this._swfEmbed.subscribe("swfReady", this._eventHandler, this, true);
64 * Fires when the SWF is initialized and communication is possible.
67 //Fix for iframe cross-domain issue with FF2x
70 this.createEvent("contentReady");
75 * Fires when the user moves the mouse over the bounds of an item renderer in the chart.
77 * @event itemMouseOverEvent
78 * @param event.type {String} The event type
79 * @param event.item {Object} The data displayed by the renderer
80 * @param event.index {Number} The position within the series that the item appears.
81 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
82 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
83 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
85 this.createEvent("itemMouseOverEvent");
88 * Fires when the user moves the mouse out of the bounds of an item renderer in the chart.
90 * @event itemMouseOutEvent
91 * @param event.type {String} The event type
92 * @param event.item {Object} The data displayed by the renderer
93 * @param event.index {Number} The position within the series that the item appears.
94 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
95 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
96 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
98 this.createEvent("itemMouseOutEvent");
101 * Fires when the user clicks an item renderer in the chart with the mouse.
103 * @event itemClickEvent
104 * @param event.type {String} The event type
105 * @param event.item {Object} The data displayed by the renderer
106 * @param event.index {Number} The position within the series that the item appears.
107 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
108 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
109 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
111 this.createEvent("itemClickEvent");
114 * Fires when the user double-clicks an item renderer in the chart with the mouse.
116 * @event itemDoubleClickEvent
117 * @param event.type {String} The event type
118 * @param event.item {Object} The data displayed by the renderer
119 * @param event.index {Number} The position within the series that the item appears.
120 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
121 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
122 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
124 this.createEvent("itemDoubleClickEvent");
127 * Fires when the user presses the mouse down on an item to initiate a drag action.
129 * @event itemDragStartEvent
130 * @param event.type {String} The event type
131 * @param event.item {Object} The data displayed by the renderer
132 * @param event.index {Number} The position within the series that the item appears.
133 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
134 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
135 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
137 this.createEvent("itemDragStartEvent");
140 * Fires when the user moves the mouse during a drag action.
142 * @event itemDragEvent
143 * @param event.type {String} The event type
144 * @param event.item {Object} The data displayed by the renderer
145 * @param event.index {Number} The position within the series that the item appears.
146 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
147 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
148 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
150 this.createEvent("itemDragEvent");
153 * Fires when the user releases the mouse during a drag action.
155 * @event itemDragEndEvent
156 * @param event.type {String} The event type
157 * @param event.item {Object} The data displayed by the renderer
158 * @param event.index {Number} The position within the series that the item appears.
159 * @param event.seriesIndex {Number} The position within the series definition that the series appears.
160 * @param event.x {Number} The horizontal position of the mouse, relative to the SWF.
161 * @param event.y {Number} The vertical position of the mouse, relative to the SWF.
163 this.createEvent("itemDragEndEvent");
166 YAHOO.extend(YAHOO.widget.Chart, YAHOO.util.AttributeProvider,
169 * The type of this chart instance.
177 * The id returned from the DataSource's setInterval function.
178 * @property _pollingID
185 * The time, in ms, between requests for data.
186 * @property _pollingInterval
190 _pollingInterval: null,
193 * Stores a reference to the dataTipFunction created by
194 * YAHOO.widget.Chart.createProxyFunction()
195 * @property _dataTipFunction
199 _dataTipFunction: null,
202 * Stores a reference to the legendLabelFunction created by
203 * YAHOO.widget.Chart.createProxyFunction()
204 * @property _legendLabelFunction
208 _legendLabelFunction: null,
211 * Stores references to series function values created by
212 * YAHOO.widget.Chart.createProxyFunction()
213 * @property _seriesFunctions
217 _seriesFunctions: null,
220 * Public accessor to the unique name of the Chart instance.
223 * @return {String} Unique name of the Chart instance.
227 return "Chart " + this._id;
231 * Sets a single style value on the Chart instance.
234 * @param name {String} Name of the Chart style value to change.
235 * @param value {Object} New value to pass to the Chart style.
237 setStyle: function(name, value)
239 //we must jsonify this because Flash Player versions below 9.0.60 don't handle
240 //complex ExternalInterface parsing correctly
241 value = YAHOO.lang.JSON.stringify(value);
242 this._swf.setStyle(name, value);
246 * Resets all styles on the Chart instance.
249 * @param styles {Object} Initializer for all Chart styles.
251 setStyles: function(styles)
253 //we must jsonify this because Flash Player versions below 9.0.60 don't handle
254 //complex ExternalInterface parsing correctly
255 styles = YAHOO.lang.JSON.stringify(styles);
256 this._swf.setStyles(styles);
260 * Sets the styles on all series in the Chart.
262 * @method setSeriesStyles
263 * @param styles {Array} Initializer for all Chart series styles.
265 setSeriesStyles: function(styles)
267 //we must jsonify this because Flash Player versions below 9.0.60 don't handle
268 //complex ExternalInterface parsing correctly
269 for(var i = 0; i < styles.length; i++)
271 styles[i] = YAHOO.lang.JSON.stringify(styles[i]);
273 this._swf.setSeriesStyles(styles);
278 //stop polling if needed
279 if(this._dataSource !== null)
281 if(this._pollingID !== null)
283 this._dataSource.clearInterval(this._pollingID);
284 this._pollingID = null;
288 //remove proxy functions
289 if(this._dataTipFunction)
291 YAHOO.widget.Chart.removeProxyFunction(this._dataTipFunction);
294 if(this._legendLabelFunction)
296 YAHOO.widget.Chart.removeProxyFunction(this._legendLabelFunction);
299 //kill the Flash Player instance
302 var container = YAHOO.util.Dom.get(this._containerID);
303 container.removeChild(this._swf);
306 var instanceName = this._id;
308 //null out properties
309 for(var prop in this)
311 if(YAHOO.lang.hasOwnProperty(this, prop))
319 * Initializes the attributes.
321 * @method _initAttributes
324 _initAttributes: function(attributes)
326 //YAHOO.widget.Chart.superclass._initAttributes.call(this, attributes);
329 * @description Sets the window mode of the Flash Player control. May be
330 * "window", "opaque", or "transparent". Only available in the constructor
331 * because it may not be set after Flash Player has been embedded in the page.
336 * @attribute expressInstall
337 * @description URL pointing to a SWF file that handles Flash Player's express
338 * install feature. Only available in the constructor because it may not be
339 * set after Flash Player has been embedded in the page.
345 * @description Minimum required version for the SWF file. Only available in the constructor because it may not be
346 * set after Flash Player has been embedded in the page.
351 * @attribute backgroundColor
352 * @description The background color of the SWF. Only available in the constructor because it may not be
353 * set after Flash Player has been embedded in the page.
359 * @description The alternative text to provide for screen readers and other assistive technology.
362 this.setAttributeConfig("altText",
364 method: this._setAltText,
365 getter: this._getAltText
371 * @description Absolute or relative URL to the SWF displayed by the Chart. Only available in the constructor because it may not be
372 * set after Flash Player has been embedded in the page.
375 this.setAttributeConfig("swfURL",
377 getter: this._getSWFURL
382 * @description Request to be sent to the Chart's DataSource.
385 this.setAttributeConfig("request",
387 method: this._setRequest,
388 getter: this._getRequest
392 * @attribute dataSource
393 * @description The DataSource instance to display in the Chart.
396 this.setAttributeConfig("dataSource",
398 method: this._setDataSource,
399 getter: this._getDataSource
404 * @description Defines the series to be displayed by the Chart.
407 this.setAttributeConfig("series",
409 method: this._setSeriesDefs,
410 getter: this._getSeriesDefs
414 * @attribute categoryNames
415 * @description Defines the names of the categories to be displayed in the Chart..
418 this.setAttributeConfig("categoryNames",
420 validator: YAHOO.lang.isArray,
421 method: this._setCategoryNames,
422 getter: this._getCategoryNames
426 * @attribute dataTipFunction
427 * @description The string representation of a globally-accessible function
428 * that may be called by the SWF to generate the datatip text for a Chart's item.
431 this.setAttributeConfig("dataTipFunction",
433 method: this._setDataTipFunction,
434 getter: this._getDataTipFunction
438 * @attribute legendLabelFunction
439 * @description The string representation of a globally-accessible function
440 * that may be called by the SWF to format the labels of a Chart's legend.
443 this.setAttributeConfig("legendLabelFunction",
445 method: this._setLegendLabelFunction,
446 getter: this._getLegendLabelFunction
451 * @description A numeric value indicating the number of milliseconds between
452 * polling requests to the DataSource.
455 this.setAttributeConfig("polling",
457 method: this._setPolling,
458 getter: this._getPolling
463 * Handles swfReady event from SWF.
465 * @method _eventHandler
468 _eventHandler: function(event)
470 if(event.type == "swfReady")
472 this._swf = this._swfEmbed._swf;
474 this.fireEvent("contentReady");
479 * Called when the SWF is ready for communication. Sets the type, initializes
480 * the styles, and sets the DataSource.
482 * @method _loadHandler
485 _loadHandler: function()
487 //the type is set separately because it must be first!
488 if(!this._swf || !this._swf.setType) return;
489 this._swf.setType(this._type);
493 if(this._attributes.style)
495 var style = this._attributes.style;
496 this.setStyles(style);
499 this._initialized = false;
501 this._initAttributes(this._attributes);
502 this.setAttributes(this._attributes, true);
504 this._initialized = true;
507 this.set("dataSource", this._dataSource);
512 * Sends (or resends) the request to the DataSource.
514 * @method refreshData
516 refreshData: function()
518 if(!this._initialized)
523 if(this._dataSource !== null)
525 if(this._pollingID !== null)
527 this._dataSource.clearInterval(this._pollingID);
528 this._pollingID = null;
531 if(this._pollingInterval > 0)
533 this._pollingID = this._dataSource.setInterval(this._pollingInterval, this._request, this._loadDataHandler, this);
535 this._dataSource.sendRequest(this._request, this._loadDataHandler, this);
540 * Called when the DataSource receives new data. The series definitions are used
541 * to build a data provider for the SWF chart.
543 * @method _loadDataHandler
546 _loadDataHandler: function(request, response, error)
556 if(this._seriesFunctions)
558 var count = this._seriesFunctions.length;
559 for(i = 0; i < count; i++)
561 YAHOO.widget.Chart.removeProxyFunction(this._seriesFunctions[i]);
563 this._seriesFunctions = null;
565 this._seriesFunctions = [];
567 //make a copy of the series definitions so that we aren't
568 //editing them directly.
569 var dataProvider = [];
571 var currentSeries = null;
572 if(this._seriesDefs !== null)
574 seriesCount = this._seriesDefs.length;
575 for(i = 0; i < seriesCount; i++)
577 currentSeries = this._seriesDefs[i];
578 var clonedSeries = {};
579 for(var prop in currentSeries)
581 if(YAHOO.lang.hasOwnProperty(currentSeries, prop))
585 if(currentSeries.style !== null)
587 clonedSeries.style = YAHOO.lang.JSON.stringify(currentSeries.style);
591 else if(prop == "labelFunction")
593 if(currentSeries.labelFunction !== null)
595 clonedSeries.labelFunction = YAHOO.widget.Chart.getFunctionReference(currentSeries.labelFunction);
596 this._seriesFunctions.push(clonedSeries.labelFunction);
600 else if(prop == "dataTipFunction")
602 if(currentSeries.dataTipFunction !== null)
604 clonedSeries.dataTipFunction = YAHOO.widget.Chart.getFunctionReference(currentSeries.dataTipFunction);
605 this._seriesFunctions.push(clonedSeries.dataTipFunction);
609 else if(prop == "legendLabelFunction")
611 if(currentSeries.legendLabelFunction !== null)
613 clonedSeries.legendLabelFunction = YAHOO.widget.Chart.getFunctionReference(currentSeries.legendLabelFunction);
614 this._seriesFunctions.push(clonedSeries.legendLabelFunction);
620 clonedSeries[prop] = currentSeries[prop];
624 dataProvider.push(clonedSeries);
630 for(i = 0; i < seriesCount; i++)
632 currentSeries = dataProvider[i];
633 if(!currentSeries.type)
635 currentSeries.type = this._type;
637 currentSeries.dataProvider = response.results;
642 var series = {type: this._type, dataProvider: response.results};
643 dataProvider.push(series);
647 if(this._swf.setDataProvider) this._swf.setDataProvider(dataProvider);
651 this._swf.setDataProvider(dataProvider);
658 * Storage for the request attribute.
666 * Getter for the request attribute.
668 * @method _getRequest
671 _getRequest: function()
673 return this._request;
677 * Setter for the request attribute.
679 * @method _setRequest
682 _setRequest: function(value)
684 this._request = value;
689 * Storage for the dataSource attribute.
691 * @property _dataSource
697 * Getter for the dataSource attribute.
699 * @method _getDataSource
702 _getDataSource: function()
704 return this._dataSource;
708 * Setter for the dataSource attribute.
710 * @method _setDataSource
713 _setDataSource: function(value)
715 this._dataSource = value;
720 * Storage for the series attribute.
722 * @property _seriesDefs
728 * Getter for the series attribute.
730 * @method _getSeriesDefs
733 _getSeriesDefs: function()
735 return this._seriesDefs;
739 * Setter for the series attribute.
741 * @method _setSeriesDefs
744 _setSeriesDefs: function(value)
746 this._seriesDefs = value;
751 * Getter for the categoryNames attribute.
753 * @method _getCategoryNames
756 _getCategoryNames: function()
758 return this._swf.getCategoryNames();
762 * Setter for the categoryNames attribute.
764 * @method _setCategoryNames
767 _setCategoryNames: function(value)
769 this._swf.setCategoryNames(value);
773 * Setter for the dataTipFunction attribute.
775 * @method _setDataTipFunction
778 _setDataTipFunction: function(value)
780 if(this._dataTipFunction)
782 YAHOO.widget.Chart.removeProxyFunction(this._dataTipFunction);
787 this._dataTipFunction = value = YAHOO.widget.Chart.getFunctionReference(value);
789 this._swf.setDataTipFunction(value);
793 * Setter for the legendLabelFunction attribute.
795 * @method _setLegendLabelFunction
798 _setLegendLabelFunction: function(value)
800 if(this._legendLabelFunction)
802 YAHOO.widget.Chart.removeProxyFunction(this._legendLabelFunction);
807 this._legendLabelFunction = value = YAHOO.widget.Chart.getFunctionReference(value);
809 this._swf.setLegendLabelFunction(value);
813 * Getter for the legendLabelFunction attribute.
815 * @method _getLegendLabelFunction
818 _getLegendLabelFunction: function()
820 return this._legendLabelFunction;
824 * Getter for the polling attribute.
826 * @method _getPolling
829 _getPolling: function()
831 return this._pollingInterval;
835 * Setter for the polling attribute.
837 * @method _setPolling
840 _setPolling: function(value)
842 this._pollingInterval = value;
847 * The javascript wrapper for the swf object
849 * @property _swfEmbed
856 * The URL of the SWF file.
864 * The ID of the containing DIV.
865 * @property _containerID
872 * A reference to the embedded SWF file.
879 * The id of this instance.
887 * Indicates whether the SWF has been initialized and is ready
888 * to communicate with JavaScript
889 * @property _initialized
896 * The initializing attributes are stored here until the SWF is ready.
897 * @property _attributes
901 _attributes: null, //the intializing attributes
903 set: function(name, value)
905 //save all the attributes in case the swf reloads
906 //so that we can pass them in again
907 this._attributes[name] = value;
908 YAHOO.widget.Chart.superclass.set.call(this, name, value);
912 * Getter for swfURL attribute.
917 _getSWFURL: function()
923 * Getter for altText attribute.
925 * @method _getAltText
928 _getAltText: function()
930 return this._swf.getAltText();
934 * Setter for altText attribute.
936 * @method _setAltText
939 _setAltText: function(value)
941 this._swf.setAltText(value);
946 * The number of proxy functions that have been created.
950 YAHOO.widget.Chart.proxyFunctionCount = 0;
953 * Creates a globally accessible function that wraps a function reference.
954 * Returns the proxy function's name as a string for use by the SWF through
957 * @method YAHOO.widget.Chart.createProxyFunction
961 YAHOO.widget.Chart.createProxyFunction = function(func, scope)
963 var scope = scope || null;
964 var index = YAHOO.widget.Chart.proxyFunctionCount;
965 YAHOO.widget.Chart["proxyFunction" + index] = function()
967 return func.apply(scope, arguments);
969 YAHOO.widget.Chart.proxyFunctionCount++;
970 return "YAHOO.widget.Chart.proxyFunction" + index.toString();
974 * Uses YAHOO.widget.Chart.createProxyFunction to return string
975 * reference to a function.
977 * @method YAHOO.widget.Chart.getFunctionReference
981 YAHOO.widget.Chart.getFunctionReference = function(value)
983 if(typeof value == "function")
985 value = YAHOO.widget.Chart.createProxyFunction(value);
987 else if(value.func && typeof value.func == "function")
989 var args = [value.func];
990 if(value.scope && typeof value.scope == "object")
992 args.push(value.scope);
994 value = YAHOO.widget.Chart.createProxyFunction.apply(this, args);
1000 * Removes a function created with createProxyFunction()
1002 * @method YAHOO.widget.Chart.removeProxyFunction
1006 YAHOO.widget.Chart.removeProxyFunction = function(funcName)
1009 if(!funcName || funcName.indexOf("YAHOO.widget.Chart.proxyFunction") < 0)
1014 funcName = funcName.substr(26);
1015 YAHOO.widget.Chart[funcName] = null;
1019 * Storage for the dataTipFunction attribute.
1021 * @property Chart.SWFURL
1025 * @default "assets/charts.swf"
1027 YAHOO.widget.Chart.SWFURL = "assets/charts.swf";
1029 * PieChart class for the YUI Charts widget.
1031 * @namespace YAHOO.widget
1033 * @uses YAHOO.widget.Chart
1035 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1036 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1037 * @param attributes {object} (optional) Object literal of configuration values.
1039 YAHOO.widget.PieChart = function(containerId, dataSource, attributes)
1041 YAHOO.widget.PieChart.superclass.constructor.call(this, "pie", containerId, dataSource, attributes);
1044 YAHOO.lang.extend(YAHOO.widget.PieChart, YAHOO.widget.Chart,
1047 * Initializes the attributes.
1049 * @method _initAttributes
1052 _initAttributes: function(attributes)
1054 YAHOO.widget.PieChart.superclass._initAttributes.call(this, attributes);
1057 * @attribute dataField
1058 * @description The field in each item that corresponds to the data value.
1061 this.setAttributeConfig("dataField",
1063 validator: YAHOO.lang.isString,
1064 method: this._setDataField,
1065 getter: this._getDataField
1069 * @attribute categoryField
1070 * @description The field in each item that corresponds to the category value.
1073 this.setAttributeConfig("categoryField",
1075 validator: YAHOO.lang.isString,
1076 method: this._setCategoryField,
1077 getter: this._getCategoryField
1082 * Getter for the dataField attribute.
1084 * @method _getDataField
1087 _getDataField: function()
1089 return this._swf.getDataField();
1093 * Setter for the dataField attribute.
1095 * @method _setDataField
1098 _setDataField: function(value)
1100 this._swf.setDataField(value);
1104 * Getter for the categoryField attribute.
1106 * @method _getCategoryField
1109 _getCategoryField: function()
1111 return this._swf.getCategoryField();
1115 * Setter for the categoryField attribute.
1117 * @method _setCategoryField
1120 _setCategoryField: function(value)
1122 this._swf.setCategoryField(value);
1126 * CartesianChart class for the YUI Charts widget.
1128 * @namespace YAHOO.widget
1129 * @class CartesianChart
1130 * @uses YAHOO.widget.Chart
1132 * @param type {String} The char type. May be "line", "column", or "bar"
1133 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1134 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1135 * @param attributes {object} (optional) Object literal of configuration values.
1137 YAHOO.widget.CartesianChart = function(type, containerId, dataSource, attributes)
1139 YAHOO.widget.CartesianChart.superclass.constructor.call(this, type, containerId, dataSource, attributes);
1142 YAHOO.lang.extend(YAHOO.widget.CartesianChart, YAHOO.widget.Chart,
1145 * Stores a reference to the xAxis labelFunction created by
1146 * YAHOO.widget.Chart.createProxyFunction()
1147 * @property _xAxisLabelFunctions
1151 _xAxisLabelFunctions: [],
1154 * Stores a reference to the yAxis labelFunctions created by
1155 * YAHOO.widget.Chart.createProxyFunction()
1156 * @property _yAxisLabelFunctions
1160 _yAxisLabelFunctions: [],
1164 //remove proxy functions
1165 this._removeAxisFunctions(this._xAxisLabelFunctions);
1166 this._removeAxisFunctions(this._yAxisLabelFunctions);
1169 YAHOO.widget.CartesianChart.superclass.destroy.call(this);
1173 * Initializes the attributes.
1175 * @method _initAttributes
1178 _initAttributes: function(attributes)
1180 YAHOO.widget.CartesianChart.superclass._initAttributes.call(this, attributes);
1184 * @description The field in each item that corresponds to a value on the x axis.
1187 this.setAttributeConfig("xField",
1189 validator: YAHOO.lang.isString,
1190 method: this._setXField,
1191 getter: this._getXField
1196 * @description The field in each item that corresponds to a value on the x axis.
1199 this.setAttributeConfig("yField",
1201 validator: YAHOO.lang.isString,
1202 method: this._setYField,
1203 getter: this._getYField
1208 * @description A custom configuration for the horizontal x axis.
1211 this.setAttributeConfig("xAxis",
1213 method: this._setXAxis
1218 * @description Custom configurations for the horizontal x axes.
1221 this.setAttributeConfig("xAxes",
1223 method: this._setXAxes
1228 * @description A custom configuration for the vertical y axis.
1231 this.setAttributeConfig("yAxis",
1233 method: this._setYAxis
1238 * @description Custom configurations for the vertical y axes.
1241 this.setAttributeConfig("yAxes",
1243 method: this._setYAxes
1247 * @attribute constrainViewport
1248 * @description Determines whether the viewport is constrained to prevent series data from overflow.
1251 this.setAttributeConfig("constrainViewport",
1253 method: this._setConstrainViewport
1258 * Getter for the xField attribute.
1260 * @method _getXField
1263 _getXField: function()
1265 return this._swf.getHorizontalField();
1269 * Setter for the xField attribute.
1271 * @method _setXField
1274 _setXField: function(value)
1276 this._swf.setHorizontalField(value);
1280 * Getter for the yField attribute.
1282 * @method _getYField
1285 _getYField: function()
1287 return this._swf.getVerticalField();
1291 * Setter for the yField attribute.
1293 * @method _setYField
1296 _setYField: function(value)
1298 this._swf.setVerticalField(value);
1302 * Receives an axis object, creates a proxy function for
1303 * the labelFunction and returns the updated object.
1305 * @method _getClonedAxis
1308 _getClonedAxis: function(value)
1310 var clonedAxis = {};
1311 for(var prop in value)
1313 if(prop == "labelFunction")
1315 if(value.labelFunction && value.labelFunction !== null)
1317 clonedAxis.labelFunction = YAHOO.widget.Chart.getFunctionReference(value.labelFunction);
1322 clonedAxis[prop] = value[prop];
1329 * Removes axis functions contained in an array
1331 * @method _removeAxisFunctions
1334 _removeAxisFunctions: function(axisFunctions)
1336 if(axisFunctions && axisFunctions.length > 0)
1338 var len = axisFunctions.length;
1339 for(var i = 0; i < len; i++)
1341 if(axisFunctions[i] !== null)
1343 YAHOO.widget.Chart.removeProxyFunction(axisFunctions[i]);
1351 * Setter for the xAxis attribute.
1356 _setXAxis: function(value)
1358 if(value.position != "bottom" && value.position != "top") value.position = "bottom";
1359 this._removeAxisFunctions(this._xAxisLabelFunctions);
1360 value = this._getClonedAxis(value);
1361 this._xAxisLabelFunctions.push(value.labelFunction);
1362 this._swf.setHorizontalAxis(value);
1366 * Setter for the xAxes attribute
1371 _setXAxes: function(value)
1373 this._removeAxisFunctions(this._xAxisLabelFunctions);
1374 var len = value.length;
1375 for(var i = 0; i < len; i++)
1377 if(value[i].position == "left") value[i].position = "bottom";
1378 value[i] = this._getClonedAxis(value[i]);
1379 if(value[i].labelFunction) this._xAxisLabelFunctions.push(value[i].labelFunction);
1380 this._swf.setHorizontalAxis(value[i]);
1385 * Setter for the yAxis attribute.
1390 _setYAxis: function(value)
1392 this._removeAxisFunctions(this._yAxisLabelFunctions);
1393 value = this._getClonedAxis(value);
1394 this._yAxisLabelFunctions.push(value.labelFunction);
1395 this._swf.setVerticalAxis(value);
1399 * Setter for the yAxes attribute.
1404 _setYAxes: function(value)
1406 this._removeAxisFunctions(this._yAxisLabelFunctions);
1407 var len = value.length;
1408 for(var i = 0; i < len; i++)
1410 value[i] = this._getClonedAxis(value[i]);
1411 if(value[i].labelFunction) this._yAxisLabelFunctions.push(value[i].labelFunction);
1412 this._swf.setVerticalAxis(value[i]);
1417 * Setter for the constrainViewport attribute
1419 * @method _setConstrainViewport
1422 _setConstrainViewport: function(value)
1424 this._swf.setConstrainViewport(value);
1428 * Sets the style object for a single series based on its index
1430 * @method setSeriesStylesByIndex
1431 * @param index {Number} The position within the series definition to apply the style
1432 * @param style {object} Style object to be applied to the selected series
1434 setSeriesStylesByIndex:function(index, style)
1436 style = YAHOO.lang.JSON.stringify(style);
1437 if(this._swf && this._swf.setSeriesStylesByIndex) this._swf.setSeriesStylesByIndex(index, style);
1441 * LineChart class for the YUI Charts widget.
1443 * @namespace YAHOO.widget
1445 * @uses YAHOO.widget.CartesianChart
1447 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1448 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1449 * @param attributes {object} (optional) Object literal of configuration values.
1451 YAHOO.widget.LineChart = function(containerId, dataSource, attributes)
1453 YAHOO.widget.LineChart.superclass.constructor.call(this, "line", containerId, dataSource, attributes);
1456 YAHOO.lang.extend(YAHOO.widget.LineChart, YAHOO.widget.CartesianChart);
1459 * ColumnChart class for the YUI Charts widget.
1461 * @namespace YAHOO.widget
1462 * @class ColumnChart
1463 * @uses YAHOO.widget.CartesianChart
1465 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1466 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1467 * @param attributes {object} (optional) Object literal of configuration values.
1469 YAHOO.widget.ColumnChart = function(containerId, dataSource, attributes)
1471 YAHOO.widget.ColumnChart.superclass.constructor.call(this, "column", containerId, dataSource, attributes);
1474 YAHOO.lang.extend(YAHOO.widget.ColumnChart, YAHOO.widget.CartesianChart);
1477 * BarChart class for the YUI Charts widget.
1479 * @namespace YAHOO.widget
1481 * @uses YAHOO.widget.CartesianChart
1483 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1484 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1485 * @param attributes {object} (optional) Object literal of configuration values.
1487 YAHOO.widget.BarChart = function(containerId, dataSource, attributes)
1489 YAHOO.widget.BarChart.superclass.constructor.call(this, "bar", containerId, dataSource, attributes);
1492 YAHOO.lang.extend(YAHOO.widget.BarChart, YAHOO.widget.CartesianChart);
1495 * StackedColumnChart class for the YUI Charts widget.
1497 * @namespace YAHOO.widget
1498 * @class StackedColumnChart
1499 * @uses YAHOO.widget.CartesianChart
1501 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1502 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1503 * @param attributes {object} (optional) Object literal of configuration values.
1505 YAHOO.widget.StackedColumnChart = function(containerId, dataSource, attributes)
1507 YAHOO.widget.StackedColumnChart.superclass.constructor.call(this, "stackcolumn", containerId, dataSource, attributes);
1510 YAHOO.lang.extend(YAHOO.widget.StackedColumnChart, YAHOO.widget.CartesianChart);
1513 * StackedBarChart class for the YUI Charts widget.
1515 * @namespace YAHOO.widget
1516 * @class StackedBarChart
1517 * @uses YAHOO.widget.CartesianChart
1519 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1520 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1521 * @param attributes {object} (optional) Object literal of configuration values.
1523 YAHOO.widget.StackedBarChart = function(containerId, dataSource, attributes)
1525 YAHOO.widget.StackedBarChart.superclass.constructor.call(this, "stackbar", containerId, dataSource, attributes);
1528 YAHOO.lang.extend(YAHOO.widget.StackedBarChart, YAHOO.widget.CartesianChart);
1530 * Defines a CartesianChart's vertical or horizontal axis.
1532 * @namespace YAHOO.widget
1536 YAHOO.widget.Axis = function()
1540 YAHOO.widget.Axis.prototype =
1551 * If true, the items on the axis will be drawn in opposite direction.
1559 * A string reference to the globally-accessible function that may be called to
1560 * determine each of the label values for this axis. Also accepts function references.
1562 * @property labelFunction
1565 labelFunction: null,
1568 * The space, in pixels, between labels on an axis.
1570 * @property labelSpacing
1576 * The text that will appear next to the axis to indicate information about the data that it displays.
1584 * A type of axis whose units are measured in numeric values.
1586 * @namespace YAHOO.widget
1587 * @class NumericAxis
1588 * @extends YAHOO.widget.Axis
1591 YAHOO.widget.NumericAxis = function()
1593 YAHOO.widget.NumericAxis.superclass.constructor.call(this);
1596 YAHOO.lang.extend(YAHOO.widget.NumericAxis, YAHOO.widget.Axis,
1601 * The minimum value drawn by the axis. If not set explicitly, the axis minimum
1602 * will be calculated automatically.
1610 * The maximum value drawn by the axis. If not set explicitly, the axis maximum
1611 * will be calculated automatically.
1619 * The spacing between major intervals on this axis.
1621 * @property majorUnit
1627 * The spacing between minor intervals on this axis.
1629 * @property minorUnit
1635 * If true, the labels, ticks, gridlines, and other objects will snap to
1636 * the nearest major or minor unit. If false, their position will be based
1637 * on the minimum value.
1639 * @property snapToUnits
1645 * Series that are stackable will only stack when this value is set to true.
1647 * @property stackingEnabled
1650 stackingEnabled: false,
1653 * If true, and the bounds are calculated automatically, either the minimum or
1654 * maximum will be set to zero.
1656 * @property alwaysShowZero
1659 alwaysShowZero: true,
1662 * The scaling algorithm to use on this axis. May be "linear" or "logarithmic".
1670 * Indicates whether to round the major unit.
1672 * @property roundMajorUnit
1675 roundMajorUnit: true,
1678 * Indicates whether to factor in the size of the labels when calculating a major unit.
1680 * @property calculateByLabelSize
1683 calculateByLabelSize: true,
1686 * Indicates the position of the axis relative to the chart
1688 * @property position
1694 * Indicates whether to extend maximum beyond data's maximum to the nearest
1697 * @property adjustMaximumByMajorUnit
1700 adjustMaximumByMajorUnit:true,
1703 * Indicates whether to extend the minimum beyond data's minimum to the nearest
1706 * @property adjustMinimumByMajorUnit
1709 adjustMinimumByMajorUnit:true
1712 * A type of axis whose units are measured in time-based values.
1714 * @namespace YAHOO.widget
1718 YAHOO.widget.TimeAxis = function()
1720 YAHOO.widget.TimeAxis.superclass.constructor.call(this);
1723 YAHOO.lang.extend(YAHOO.widget.TimeAxis, YAHOO.widget.Axis,
1728 * The minimum value drawn by the axis. If not set explicitly, the axis minimum
1729 * will be calculated automatically.
1737 * The maximum value drawn by the axis. If not set explicitly, the axis maximum
1738 * will be calculated automatically.
1746 * The spacing between major intervals on this axis.
1748 * @property majorUnit
1754 * The time unit used by the majorUnit.
1756 * @property majorTimeUnit
1759 majorTimeUnit: null,
1762 * The spacing between minor intervals on this axis.
1764 * @property majorUnit
1770 * The time unit used by the minorUnit.
1772 * @property majorTimeUnit
1775 minorTimeUnit: null,
1778 * If true, the labels, ticks, gridlines, and other objects will snap to
1779 * the nearest major or minor unit. If false, their position will be based
1780 * on the minimum value.
1782 * @property snapToUnits
1788 * Series that are stackable will only stack when this value is set to true.
1790 * @property stackingEnabled
1793 stackingEnabled: false,
1796 * Indicates whether to factor in the size of the labels when calculating a major unit.
1798 * @property calculateByLabelSize
1801 calculateByLabelSize: true
1804 * A type of axis that displays items in categories.
1806 * @namespace YAHOO.widget
1807 * @class CategoryAxis
1810 YAHOO.widget.CategoryAxis = function()
1812 YAHOO.widget.CategoryAxis.superclass.constructor.call(this);
1815 YAHOO.lang.extend(YAHOO.widget.CategoryAxis, YAHOO.widget.Axis,
1820 * A list of category names to display along this axis.
1822 * @property categoryNames
1825 categoryNames: null,
1828 * Indicates whether or not to calculate the number of categories (ticks and labels)
1829 * when there is not enough room to display all labels on the axis. If set to true, the axis
1830 * will determine the number of categories to plot. If not, all categories will be plotted.
1832 * @property calculateCategoryCount
1835 calculateCategoryCount: false
1838 * Functionality common to most series. Generally, a <code>Series</code>
1839 * object shouldn't be instantiated directly. Instead, a subclass with a
1840 * concrete implementation should be used.
1842 * @namespace YAHOO.widget
1846 YAHOO.widget.Series = function() {};
1848 YAHOO.widget.Series.prototype =
1851 * The type of series.
1859 * The human-readable name of the series.
1861 * @property displayName
1868 * Functionality common to most series appearing in cartesian charts.
1869 * Generally, a <code>CartesianSeries</code> object shouldn't be
1870 * instantiated directly. Instead, a subclass with a concrete implementation
1873 * @namespace YAHOO.widget
1874 * @class CartesianSeries
1875 * @uses YAHOO.widget.Series
1878 YAHOO.widget.CartesianSeries = function()
1880 YAHOO.widget.CartesianSeries.superclass.constructor.call(this);
1883 YAHOO.lang.extend(YAHOO.widget.CartesianSeries, YAHOO.widget.Series,
1886 * The field used to access the x-axis value from the items from the data source.
1894 * The field used to access the y-axis value from the items from the data source.
1902 * Indicates which axis the series will bind to
1910 * When a Legend is present, indicates whether the series will show in the legend.
1912 * @property showInLegend
1919 * ColumnSeries class for the YUI Charts widget.
1921 * @namespace YAHOO.widget
1922 * @class ColumnSeries
1923 * @uses YAHOO.widget.CartesianSeries
1926 YAHOO.widget.ColumnSeries = function()
1928 YAHOO.widget.ColumnSeries.superclass.constructor.call(this);
1931 YAHOO.lang.extend(YAHOO.widget.ColumnSeries, YAHOO.widget.CartesianSeries,
1937 * LineSeries class for the YUI Charts widget.
1939 * @namespace YAHOO.widget
1941 * @uses YAHOO.widget.CartesianSeries
1944 YAHOO.widget.LineSeries = function()
1946 YAHOO.widget.LineSeries.superclass.constructor.call(this);
1949 YAHOO.lang.extend(YAHOO.widget.LineSeries, YAHOO.widget.CartesianSeries,
1956 * BarSeries class for the YUI Charts widget.
1958 * @namespace YAHOO.widget
1960 * @uses YAHOO.widget.CartesianSeries
1963 YAHOO.widget.BarSeries = function()
1965 YAHOO.widget.BarSeries.superclass.constructor.call(this);
1968 YAHOO.lang.extend(YAHOO.widget.BarSeries, YAHOO.widget.CartesianSeries,
1975 * PieSeries class for the YUI Charts widget.
1977 * @namespace YAHOO.widget
1979 * @uses YAHOO.widget.Series
1982 YAHOO.widget.PieSeries = function()
1984 YAHOO.widget.PieSeries.superclass.constructor.call(this);
1987 YAHOO.lang.extend(YAHOO.widget.PieSeries, YAHOO.widget.Series,
1992 * The field used to access the data value from the items from the data source.
1994 * @property dataField
2000 * The field used to access the category value from the items from the data source.
2002 * @property categoryField
2005 categoryField: null,
2008 * A string reference to the globally-accessible function that may be called to
2009 * determine each of the label values for this series. Also accepts function references.
2011 * @property labelFunction
2018 * StackedBarSeries class for the YUI Charts widget.
2020 * @namespace YAHOO.widget
2021 * @class StackedBarSeries
2022 * @uses YAHOO.widget.CartesianSeries
2025 YAHOO.widget.StackedBarSeries = function()
2027 YAHOO.widget.StackedBarSeries.superclass.constructor.call(this);
2030 YAHOO.lang.extend(YAHOO.widget.StackedBarSeries, YAHOO.widget.CartesianSeries,
2036 * StackedColumnSeries class for the YUI Charts widget.
2038 * @namespace YAHOO.widget
2039 * @class StackedColumnSeries
2040 * @uses YAHOO.widget.CartesianSeries
2043 YAHOO.widget.StackedColumnSeries = function()
2045 YAHOO.widget.StackedColumnSeries.superclass.constructor.call(this);
2048 YAHOO.lang.extend(YAHOO.widget.StackedColumnSeries, YAHOO.widget.CartesianSeries,
2052 YAHOO.register("charts", YAHOO.widget.Chart, {version: "2.9.0", build: "2800"});