2 Copyright (c) 2009, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.net/yui/license.txt
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
17 /****************************************************************************/
18 /****************************************************************************/
19 /****************************************************************************/
22 * Chart class for the YUI Charts widget.
24 * @namespace YAHOO.widget
26 * @uses YAHOO.util.AttributeProvider
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.
33 YAHOO.widget.Chart = function(type, containerId, dataSource, configurationAttributes)
36 this._dataSource = dataSource;
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};
41 for(var i in configurationAttributes)
43 if(possibleParams.hasOwnProperty(i))
45 attributes.fixedAttributes[i] = configurationAttributes[i];
49 attributes[i] = configurationAttributes[i];
53 this._id = attributes.id = attributes.id || YAHOO.util.Dom.generateId(null, "yuigen");
55 if(attributes.version && attributes.version != null && attributes.version != undefined && attributes.version != "undefined")
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)
69 version += verSplit[1];
70 attributes.version = parseFloat(version);
73 this._swfURL = YAHOO.widget.Chart.SWFURL;
74 this._containerID = containerId;
76 this._attributes = attributes
77 this._swfEmbed = new YAHOO.widget.SWF(containerId, YAHOO.widget.Chart.SWFURL, attributes);
79 this._swf = this._swfEmbed.swf;
80 this._swfEmbed.subscribe("swfReady", this._eventHandler, this, true);
83 * Fires when the SWF is initialized and communication is possible.
86 //Fix for iframe cross-domain issue with FF2x
89 this.createEvent("contentReady");
94 * Fires when the user moves the mouse over the bounds of an item renderer in the chart.
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.
104 this.createEvent("itemMouseOverEvent");
107 * Fires when the user moves the mouse out of the bounds of an item renderer in the chart.
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.
117 this.createEvent("itemMouseOutEvent");
120 * Fires when the user clicks an item renderer in the chart with the mouse.
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.
130 this.createEvent("itemClickEvent");
133 * Fires when the user double-clicks an item renderer in the chart with the mouse.
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.
143 this.createEvent("itemDoubleClickEvent");
146 * Fires when the user presses the mouse down on an item to initiate a drag action.
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.
156 this.createEvent("itemDragStartEvent");
159 * Fires when the user moves the mouse during a drag action.
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.
169 this.createEvent("itemDragEvent");
172 * Fires when the user releases the mouse during a drag action.
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.
182 this.createEvent("itemDragEndEvent");
185 YAHOO.extend(YAHOO.widget.Chart, YAHOO.util.AttributeProvider,
188 * The type of this chart instance.
196 * The id returned from the DataSource's setInterval function.
197 * @property _pollingID
204 * The time, in ms, between requests for data.
205 * @property _pollingInterval
209 _pollingInterval: null,
212 * Stores a reference to the dataTipFunction created by
213 * YAHOO.widget.Chart.createProxyFunction()
214 * @property _dataTipFunction
218 _dataTipFunction: null,
221 * Stores a reference to the legendLabelFunction created by
222 * YAHOO.widget.Chart.createProxyFunction()
223 * @property _legendLabelFunction
227 _legendLabelFunction: null,
230 * Stores references to series function values created by
231 * YAHOO.widget.Chart.createProxyFunction()
232 * @property _seriesFunctions
236 _seriesFunctions: null,
239 * Public accessor to the unique name of the Chart instance.
242 * @return {String} Unique name of the Chart instance.
246 return "Chart " + this._id;
250 * Sets a single style value on the Chart instance.
253 * @param name {String} Name of the Chart style value to change.
254 * @param value {Object} New value to pass to the Chart style.
256 setStyle: function(name, value)
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);
265 * Resets all styles on the Chart instance.
268 * @param styles {Object} Initializer for all Chart styles.
270 setStyles: function(styles)
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);
279 * Sets the styles on all series in the Chart.
281 * @method setSeriesStyles
282 * @param styles {Array} Initializer for all Chart series styles.
284 setSeriesStyles: function(styles)
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++)
290 styles[i] = YAHOO.lang.JSON.stringify(styles[i]);
292 this._swf.setSeriesStyles(styles);
297 //stop polling if needed
298 if(this._dataSource !== null)
300 if(this._pollingID !== null)
302 this._dataSource.clearInterval(this._pollingID);
303 this._pollingID = null;
307 //remove proxy functions
308 if(this._dataTipFunction)
310 YAHOO.widget.Chart.removeProxyFunction(this._dataTipFunction);
313 if(this._legendLabelFunction)
315 YAHOO.widget.Chart.removeProxyFunction(this._legendLabelFunction);
318 //kill the Flash Player instance
321 var container = YAHOO.util.Dom.get(this._containerID);
322 container.removeChild(this._swf);
325 var instanceName = this._id;
327 //null out properties
328 for(var prop in this)
330 if(YAHOO.lang.hasOwnProperty(this, prop))
338 * Initializes the attributes.
340 * @method _initAttributes
343 _initAttributes: function(attributes)
345 //YAHOO.widget.Chart.superclass._initAttributes.call(this, attributes);
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.
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.
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.
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.
378 * @description The alternative text to provide for screen readers and other assistive technology.
381 this.setAttributeConfig("altText",
383 method: this._setAltText,
384 getter: this._getAltText
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.
394 this.setAttributeConfig("swfURL",
396 getter: this._getSWFURL
401 * @description Request to be sent to the Chart's DataSource.
404 this.setAttributeConfig("request",
406 method: this._setRequest,
407 getter: this._getRequest
411 * @attribute dataSource
412 * @description The DataSource instance to display in the Chart.
415 this.setAttributeConfig("dataSource",
417 method: this._setDataSource,
418 getter: this._getDataSource
423 * @description Defines the series to be displayed by the Chart.
426 this.setAttributeConfig("series",
428 method: this._setSeriesDefs,
429 getter: this._getSeriesDefs
433 * @attribute categoryNames
434 * @description Defines the names of the categories to be displayed in the Chart..
437 this.setAttributeConfig("categoryNames",
439 validator: YAHOO.lang.isArray,
440 method: this._setCategoryNames,
441 getter: this._getCategoryNames
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.
450 this.setAttributeConfig("dataTipFunction",
452 method: this._setDataTipFunction,
453 getter: this._getDataTipFunction
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.
462 this.setAttributeConfig("legendLabelFunction",
464 method: this._setLegendLabelFunction,
465 getter: this._legendLabelFunction
470 * @description A numeric value indicating the number of milliseconds between
471 * polling requests to the DataSource.
474 this.setAttributeConfig("polling",
476 method: this._setPolling,
477 getter: this._getPolling
482 * Handles swfReady event from SWF.
484 * @method _eventHandler
487 _eventHandler: function(event)
489 if(event.type == "swfReady")
491 this._swf = this._swfEmbed._swf;
493 this.fireEvent("contentReady");
498 * Called when the SWF is ready for communication. Sets the type, initializes
499 * the styles, and sets the DataSource.
501 * @method _loadHandler
504 _loadHandler: function()
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);
512 if(this._attributes.style)
514 var style = this._attributes.style;
515 this.setStyles(style);
518 this._initialized = false;
520 this._initAttributes(this._attributes);
521 this.setAttributes(this._attributes, true);
523 this._initialized = true;
526 this.set("dataSource", this._dataSource);
531 * Sends (or resends) the request to the DataSource.
533 * @method refreshData
535 refreshData: function()
537 if(!this._initialized)
542 if(this._dataSource !== null)
544 if(this._pollingID !== null)
546 this._dataSource.clearInterval(this._pollingID);
547 this._pollingID = null;
550 if(this._pollingInterval > 0)
552 this._pollingID = this._dataSource.setInterval(this._pollingInterval, this._request, this._loadDataHandler, this);
554 this._dataSource.sendRequest(this._request, this._loadDataHandler, this);
559 * Called when the DataSource receives new data. The series definitions are used
560 * to build a data provider for the SWF chart.
562 * @method _loadDataHandler
565 _loadDataHandler: function(request, response, error)
571 YAHOO.log("Unable to load data.", "error");
576 if(this._seriesFunctions)
578 var count = this._seriesFunctions.length;
579 for(i = 0; i < count; i++)
581 YAHOO.widget.Chart.removeProxyFunction(this._seriesFunctions[i]);
583 this._seriesFunctions = null;
585 this._seriesFunctions = [];
587 //make a copy of the series definitions so that we aren't
588 //editing them directly.
589 var dataProvider = [];
591 var currentSeries = null;
592 if(this._seriesDefs !== null)
594 seriesCount = this._seriesDefs.length;
595 for(i = 0; i < seriesCount; i++)
597 currentSeries = this._seriesDefs[i];
598 var clonedSeries = {};
599 for(var prop in currentSeries)
601 if(YAHOO.lang.hasOwnProperty(currentSeries, prop))
605 if(currentSeries.style !== null)
607 clonedSeries.style = YAHOO.lang.JSON.stringify(currentSeries.style);
611 else if(prop == "labelFunction")
613 if(currentSeries.labelFunction !== null)
615 clonedSeries.labelFunction = YAHOO.widget.Chart.getFunctionReference(currentSeries.labelFunction);
616 this._seriesFunctions.push(clonedSeries.labelFunction);
620 else if(prop == "dataTipFunction")
622 if(currentSeries.dataTipFunction !== null)
624 clonedSeries.dataTipFunction = YAHOO.widget.Chart.getFunctionReference(currentSeries.dataTipFunction);
625 this._seriesFunctions.push(clonedSeries.dataTipFunction);
629 else if(prop == "legendLabelFunction")
631 if(currentSeries.legendLabelFunction !== null)
633 clonedSeries.legendLabelFunction = YAHOO.widget.Chart.getFunctionReference(currentSeries.legendLabelFunction);
634 this._seriesFunctions.push(clonedSeries.legendLabelFunction);
640 clonedSeries[prop] = currentSeries[prop];
644 dataProvider.push(clonedSeries);
650 for(i = 0; i < seriesCount; i++)
652 currentSeries = dataProvider[i];
653 if(!currentSeries.type)
655 currentSeries.type = this._type;
657 currentSeries.dataProvider = response.results;
662 var series = {type: this._type, dataProvider: response.results};
663 dataProvider.push(series);
667 if(this._swf.setDataProvider) this._swf.setDataProvider(dataProvider);
671 this._swf.setDataProvider(dataProvider);
678 * Storage for the request attribute.
686 * Getter for the request attribute.
688 * @method _getRequest
691 _getRequest: function()
693 return this._request;
697 * Setter for the request attribute.
699 * @method _setRequest
702 _setRequest: function(value)
704 this._request = value;
709 * Storage for the dataSource attribute.
711 * @property _dataSource
717 * Getter for the dataSource attribute.
719 * @method _getDataSource
722 _getDataSource: function()
724 return this._dataSource;
728 * Setter for the dataSource attribute.
730 * @method _setDataSource
733 _setDataSource: function(value)
735 this._dataSource = value;
740 * Storage for the series attribute.
742 * @property _seriesDefs
748 * Getter for the series attribute.
750 * @method _getSeriesDefs
753 _getSeriesDefs: function()
755 return this._seriesDefs;
759 * Setter for the series attribute.
761 * @method _setSeriesDefs
764 _setSeriesDefs: function(value)
766 this._seriesDefs = value;
771 * Getter for the categoryNames attribute.
773 * @method _getCategoryNames
776 _getCategoryNames: function()
778 return this._swf.getCategoryNames();
782 * Setter for the categoryNames attribute.
784 * @method _setCategoryNames
787 _setCategoryNames: function(value)
789 this._swf.setCategoryNames(value);
793 * Setter for the dataTipFunction attribute.
795 * @method _setDataTipFunction
798 _setDataTipFunction: function(value)
800 if(this._dataTipFunction)
802 YAHOO.widget.Chart.removeProxyFunction(this._dataTipFunction);
807 this._dataTipFunction = value = YAHOO.widget.Chart.getFunctionReference(value);
809 this._swf.setDataTipFunction(value);
813 * Setter for the legendLabelFunction attribute.
815 * @method _setLegendLabelFunction
818 _setLegendLabelFunction: function(value)
820 if(this._legendLabelFunction)
822 YAHOO.widget.Chart.removeProxyFunction(this._legendLabelFunction);
827 this._legendLabelFunction = value = YAHOO.widget.Chart.getFunctionReference(value);
829 this._swf.setLegendLabelFunction(value);
833 * Getter for the polling attribute.
835 * @method _getPolling
838 _getPolling: function()
840 return this._pollingInterval;
844 * Setter for the polling attribute.
846 * @method _setPolling
849 _setPolling: function(value)
851 this._pollingInterval = value;
856 * The javascript wrapper for the swf object
858 * @property _swfEmbed
865 * The URL of the SWF file.
873 * The ID of the containing DIV.
874 * @property _containerID
881 * A reference to the embedded SWF file.
888 * The id of this instance.
896 * Indicates whether the SWF has been initialized and is ready
897 * to communicate with JavaScript
898 * @property _initialized
905 * The initializing attributes are stored here until the SWF is ready.
906 * @property _attributes
910 _attributes: null, //the intializing attributes
912 set: function(name, value)
914 //save all the attributes in case the swf reloads
915 //so that we can pass them in again
916 this._attributes[name] = value;
917 YAHOO.widget.Chart.superclass.set.call(this, name, value);
921 * Getter for swfURL attribute.
926 _getSWFURL: function()
932 * Getter for altText attribute.
934 * @method _getAltText
937 _getAltText: function()
939 return this._swf.getAltText();
943 * Setter for altText attribute.
945 * @method _setAltText
948 _setAltText: function(value)
950 this._swf.setAltText(value);
955 * The number of proxy functions that have been created.
959 YAHOO.widget.Chart.proxyFunctionCount = 0;
962 * Creates a globally accessible function that wraps a function reference.
963 * Returns the proxy function's name as a string for use by the SWF through
966 * @method YAHOO.widget.Chart.createProxyFunction
970 YAHOO.widget.Chart.createProxyFunction = function(func, scope)
972 var scope = scope || null;
973 var index = YAHOO.widget.Chart.proxyFunctionCount;
974 YAHOO.widget.Chart["proxyFunction" + index] = function()
976 return func.apply(scope, arguments);
978 YAHOO.widget.Chart.proxyFunctionCount++;
979 return "YAHOO.widget.Chart.proxyFunction" + index.toString();
983 * Uses YAHOO.widget.Chart.createProxyFunction to return string
984 * reference to a function.
986 * @method YAHOO.widget.Chart.getFunctionReference
990 YAHOO.widget.Chart.getFunctionReference = function(value)
992 if(typeof value == "function")
994 value = YAHOO.widget.Chart.createProxyFunction(value);
996 else if(value.func && typeof value.func == "function")
998 var args = [value.func];
999 if(value.scope && typeof value.scope == "object")
1001 args.push(value.scope);
1003 value = YAHOO.widget.Chart.createProxyFunction.apply(this, args);
1009 * Removes a function created with createProxyFunction()
1011 * @method YAHOO.widget.Chart.removeProxyFunction
1015 YAHOO.widget.Chart.removeProxyFunction = function(funcName)
1018 if(!funcName || funcName.indexOf("YAHOO.widget.Chart.proxyFunction") < 0)
1023 funcName = funcName.substr(26);
1024 YAHOO.widget.Chart[funcName] = null;
1028 * Storage for the dataTipFunction attribute.
1030 * @property Chart.SWFURL
1034 * @default "assets/charts.swf"
1036 YAHOO.widget.Chart.SWFURL = "assets/charts.swf";
1038 * PieChart class for the YUI Charts widget.
1040 * @namespace YAHOO.widget
1042 * @uses YAHOO.widget.Chart
1044 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1045 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1046 * @param attributes {object} (optional) Object literal of configuration values.
1048 YAHOO.widget.PieChart = function(containerId, dataSource, attributes)
1050 YAHOO.widget.PieChart.superclass.constructor.call(this, "pie", containerId, dataSource, attributes);
1053 YAHOO.lang.extend(YAHOO.widget.PieChart, YAHOO.widget.Chart,
1056 * Initializes the attributes.
1058 * @method _initAttributes
1061 _initAttributes: function(attributes)
1063 YAHOO.widget.PieChart.superclass._initAttributes.call(this, attributes);
1066 * @attribute dataField
1067 * @description The field in each item that corresponds to the data value.
1070 this.setAttributeConfig("dataField",
1072 validator: YAHOO.lang.isString,
1073 method: this._setDataField,
1074 getter: this._getDataField
1078 * @attribute categoryField
1079 * @description The field in each item that corresponds to the category value.
1082 this.setAttributeConfig("categoryField",
1084 validator: YAHOO.lang.isString,
1085 method: this._setCategoryField,
1086 getter: this._getCategoryField
1091 * Getter for the dataField attribute.
1093 * @method _getDataField
1096 _getDataField: function()
1098 return this._swf.getDataField();
1102 * Setter for the dataField attribute.
1104 * @method _setDataField
1107 _setDataField: function(value)
1109 this._swf.setDataField(value);
1113 * Getter for the categoryField attribute.
1115 * @method _getCategoryField
1118 _getCategoryField: function()
1120 return this._swf.getCategoryField();
1124 * Setter for the categoryField attribute.
1126 * @method _setCategoryField
1129 _setCategoryField: function(value)
1131 this._swf.setCategoryField(value);
1135 * CartesianChart class for the YUI Charts widget.
1137 * @namespace YAHOO.widget
1138 * @class CartesianChart
1139 * @uses YAHOO.widget.Chart
1141 * @param type {String} The char type. May be "line", "column", or "bar"
1142 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1143 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1144 * @param attributes {object} (optional) Object literal of configuration values.
1146 YAHOO.widget.CartesianChart = function(type, containerId, dataSource, attributes)
1148 YAHOO.widget.CartesianChart.superclass.constructor.call(this, type, containerId, dataSource, attributes);
1151 YAHOO.lang.extend(YAHOO.widget.CartesianChart, YAHOO.widget.Chart,
1154 * Stores a reference to the xAxis labelFunction created by
1155 * YAHOO.widget.Chart.createProxyFunction()
1156 * @property _xAxisLabelFunctions
1160 _xAxisLabelFunctions: [],
1163 * Stores a reference to the yAxis labelFunctions created by
1164 * YAHOO.widget.Chart.createProxyFunction()
1165 * @property _yAxisLabelFunctions
1169 _yAxisLabelFunctions: [],
1173 //remove proxy functions
1174 this._removeAxisFunctions(this._xAxisLabelFunctions);
1175 this._removeAxisFunctions(this._yAxisLabelFunctions);
1178 YAHOO.widget.CartesianChart.superclass.destroy.call(this);
1182 * Initializes the attributes.
1184 * @method _initAttributes
1187 _initAttributes: function(attributes)
1189 YAHOO.widget.CartesianChart.superclass._initAttributes.call(this, attributes);
1193 * @description The field in each item that corresponds to a value on the x axis.
1196 this.setAttributeConfig("xField",
1198 validator: YAHOO.lang.isString,
1199 method: this._setXField,
1200 getter: this._getXField
1205 * @description The field in each item that corresponds to a value on the x axis.
1208 this.setAttributeConfig("yField",
1210 validator: YAHOO.lang.isString,
1211 method: this._setYField,
1212 getter: this._getYField
1217 * @description A custom configuration for the horizontal x axis.
1220 this.setAttributeConfig("xAxis",
1222 method: this._setXAxis
1227 * @description Custom configurations for the horizontal x axes.
1230 this.setAttributeConfig("xAxes",
1232 method: this._setXAxes
1237 * @description A custom configuration for the vertical y axis.
1240 this.setAttributeConfig("yAxis",
1242 method: this._setYAxis
1247 * @description Custom configurations for the vertical y axes.
1250 this.setAttributeConfig("yAxes",
1252 method: this._setYAxes
1256 * @attribute constrainViewport
1257 * @description Determines whether the viewport is constrained to prevent series data from overflow.
1260 this.setAttributeConfig("constrainViewport",
1262 method: this._setConstrainViewport
1267 * Getter for the xField attribute.
1269 * @method _getXField
1272 _getXField: function()
1274 return this._swf.getHorizontalField();
1278 * Setter for the xField attribute.
1280 * @method _setXField
1283 _setXField: function(value)
1285 this._swf.setHorizontalField(value);
1289 * Getter for the yField attribute.
1291 * @method _getYField
1294 _getYField: function()
1296 return this._swf.getVerticalField();
1300 * Setter for the yField attribute.
1302 * @method _setYField
1305 _setYField: function(value)
1307 this._swf.setVerticalField(value);
1311 * Receives an axis object, creates a proxy function for
1312 * the labelFunction and returns the updated object.
1314 * @method _getClonedAxis
1317 _getClonedAxis: function(value)
1319 var clonedAxis = {};
1320 for(var prop in value)
1322 if(prop == "labelFunction")
1324 if(value.labelFunction && value.labelFunction !== null)
1326 clonedAxis.labelFunction = YAHOO.widget.Chart.getFunctionReference(value.labelFunction);
1331 clonedAxis[prop] = value[prop];
1338 * Removes axis functions contained in an array
1340 * @method _removeAxisFunctions
1343 _removeAxisFunctions: function(axisFunctions)
1345 if(axisFunctions && axisFunctions.length > 0)
1347 var len = axisFunctions.length;
1348 for(var i = 0; i < len; i++)
1350 if(axisFunctions[i] !== null)
1352 YAHOO.widget.Chart.removeProxyFunction(axisFunctions[i]);
1360 * Setter for the xAxis attribute.
1365 _setXAxis: function(value)
1367 if(value.position != "bottom" && value.position != "top") value.position = "bottom";
1368 this._removeAxisFunctions(this._xAxisLabelFunctions);
1369 value = this._getClonedAxis(value);
1370 this._xAxisLabelFunctions.push(value.labelFunction);
1371 this._swf.setHorizontalAxis(value);
1375 * Setter for the xAxes attribute
1380 _setXAxes: function(value)
1382 this._removeAxisFunctions(this._xAxisLabelFunctions);
1383 var len = value.length;
1384 for(var i = 0; i < len; i++)
1386 if(value[i].position == "left") value[i].position = "bottom";
1387 value[i] = this._getClonedAxis(value[i]);
1388 if(value[i].labelFunction) this._xAxisLabelFunctions.push(value[i].labelFunction);
1389 this._swf.setHorizontalAxis(value[i]);
1394 * Setter for the yAxis attribute.
1399 _setYAxis: function(value)
1401 this._removeAxisFunctions(this._yAxisLabelFunctions);
1402 value = this._getClonedAxis(value);
1403 this._yAxisLabelFunctions.push(value.labelFunction);
1404 this._swf.setVerticalAxis(value);
1408 * Setter for the yAxes attribute.
1413 _setYAxes: function(value)
1415 this._removeAxisFunctions(this._yAxisLabelFunctions);
1416 var len = value.length;
1417 for(var i = 0; i < len; i++)
1419 value[i] = this._getClonedAxis(value[i]);
1420 if(value[i].labelFunction) this._yAxisLabelFunctions.push(value[i].labelFunction);
1421 this._swf.setVerticalAxis(value[i]);
1426 * Setter for the constrainViewport attribute
1428 * @method _setConstrainViewport
1431 _setConstrainViewport: function(value)
1433 this._swf.setConstrainViewport(value);
1437 * Sets the style object for a single series based on its index
1439 * @method setSeriesStylesByIndex
1440 * @param index {Number} The position within the series definition to apply the style
1441 * @param style {object} Style object to be applied to the selected series
1443 setSeriesStylesByIndex:function(index, style)
1445 style = YAHOO.lang.JSON.stringify(style);
1446 if(this._swf && this._swf.setSeriesStylesByIndex) this._swf.setSeriesStylesByIndex(index, style);
1450 * LineChart class for the YUI Charts widget.
1452 * @namespace YAHOO.widget
1454 * @uses YAHOO.widget.CartesianChart
1456 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1457 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1458 * @param attributes {object} (optional) Object literal of configuration values.
1460 YAHOO.widget.LineChart = function(containerId, dataSource, attributes)
1462 YAHOO.widget.LineChart.superclass.constructor.call(this, "line", containerId, dataSource, attributes);
1465 YAHOO.lang.extend(YAHOO.widget.LineChart, YAHOO.widget.CartesianChart);
1468 * ColumnChart class for the YUI Charts widget.
1470 * @namespace YAHOO.widget
1471 * @class ColumnChart
1472 * @uses YAHOO.widget.CartesianChart
1474 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1475 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1476 * @param attributes {object} (optional) Object literal of configuration values.
1478 YAHOO.widget.ColumnChart = function(containerId, dataSource, attributes)
1480 YAHOO.widget.ColumnChart.superclass.constructor.call(this, "column", containerId, dataSource, attributes);
1483 YAHOO.lang.extend(YAHOO.widget.ColumnChart, YAHOO.widget.CartesianChart);
1486 * BarChart class for the YUI Charts widget.
1488 * @namespace YAHOO.widget
1490 * @uses YAHOO.widget.CartesianChart
1492 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1493 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1494 * @param attributes {object} (optional) Object literal of configuration values.
1496 YAHOO.widget.BarChart = function(containerId, dataSource, attributes)
1498 YAHOO.widget.BarChart.superclass.constructor.call(this, "bar", containerId, dataSource, attributes);
1501 YAHOO.lang.extend(YAHOO.widget.BarChart, YAHOO.widget.CartesianChart);
1504 * StackedColumnChart class for the YUI Charts widget.
1506 * @namespace YAHOO.widget
1507 * @class StackedColumnChart
1508 * @uses YAHOO.widget.CartesianChart
1510 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1511 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1512 * @param attributes {object} (optional) Object literal of configuration values.
1514 YAHOO.widget.StackedColumnChart = function(containerId, dataSource, attributes)
1516 YAHOO.widget.StackedColumnChart.superclass.constructor.call(this, "stackcolumn", containerId, dataSource, attributes);
1519 YAHOO.lang.extend(YAHOO.widget.StackedColumnChart, YAHOO.widget.CartesianChart);
1522 * StackedBarChart class for the YUI Charts widget.
1524 * @namespace YAHOO.widget
1525 * @class StackedBarChart
1526 * @uses YAHOO.widget.CartesianChart
1528 * @param containerId {HTMLElement} Container element for the Flash Player instance.
1529 * @param dataSource {YAHOO.util.DataSource} DataSource instance.
1530 * @param attributes {object} (optional) Object literal of configuration values.
1532 YAHOO.widget.StackedBarChart = function(containerId, dataSource, attributes)
1534 YAHOO.widget.StackedBarChart.superclass.constructor.call(this, "stackbar", containerId, dataSource, attributes);
1537 YAHOO.lang.extend(YAHOO.widget.StackedBarChart, YAHOO.widget.CartesianChart);
1539 * Defines a CartesianChart's vertical or horizontal axis.
1541 * @namespace YAHOO.widget
1545 YAHOO.widget.Axis = function()
1549 YAHOO.widget.Axis.prototype =
1560 * If true, the items on the axis will be drawn in opposite direction.
1568 * A string reference to the globally-accessible function that may be called to
1569 * determine each of the label values for this axis. Also accepts function references.
1571 * @property labelFunction
1574 labelFunction: null,
1577 * The space, in pixels, between labels on an axis.
1579 * @property labelSpacing
1585 * The text that will appear next to the axis to indicate information about the data that it displays.
1593 * A type of axis whose units are measured in numeric values.
1595 * @namespace YAHOO.widget
1596 * @class NumericAxis
1597 * @extends YAHOO.widget.Axis
1600 YAHOO.widget.NumericAxis = function()
1602 YAHOO.widget.NumericAxis.superclass.constructor.call(this);
1605 YAHOO.lang.extend(YAHOO.widget.NumericAxis, YAHOO.widget.Axis,
1610 * The minimum value drawn by the axis. If not set explicitly, the axis minimum
1611 * will be calculated automatically.
1619 * The maximum value drawn by the axis. If not set explicitly, the axis maximum
1620 * will be calculated automatically.
1628 * The spacing between major intervals on this axis.
1630 * @property majorUnit
1636 * The spacing between minor intervals on this axis.
1638 * @property minorUnit
1644 * If true, the labels, ticks, gridlines, and other objects will snap to
1645 * the nearest major or minor unit. If false, their position will be based
1646 * on the minimum value.
1648 * @property snapToUnits
1654 * Series that are stackable will only stack when this value is set to true.
1656 * @property stackingEnabled
1659 stackingEnabled: false,
1662 * If true, and the bounds are calculated automatically, either the minimum or
1663 * maximum will be set to zero.
1665 * @property alwaysShowZero
1668 alwaysShowZero: true,
1671 * The scaling algorithm to use on this axis. May be "linear" or "logarithmic".
1679 * Indicates whether to round the major unit.
1681 * @property roundMajorUnit
1684 roundMajorUnit: true,
1687 * Indicates whether to factor in the size of the labels when calculating a major unit.
1689 * @property calculateByLabelSize
1692 calculateByLabelSize: true,
1695 * Indicates the position of the axis relative to the chart
1697 * @property position
1703 * Indicates whether to extend maximum beyond data's maximum to the nearest
1706 * @property adjustMaximumByMajorUnit
1709 adjustMaximumByMajorUnit:true,
1712 * Indicates whether to extend the minimum beyond data's minimum to the nearest
1715 * @property adjustMinimumByMajorUnit
1718 adjustMinimumByMajorUnit:true
1721 * A type of axis whose units are measured in time-based values.
1723 * @namespace YAHOO.widget
1727 YAHOO.widget.TimeAxis = function()
1729 YAHOO.widget.TimeAxis.superclass.constructor.call(this);
1732 YAHOO.lang.extend(YAHOO.widget.TimeAxis, YAHOO.widget.Axis,
1737 * The minimum value drawn by the axis. If not set explicitly, the axis minimum
1738 * will be calculated automatically.
1746 * The maximum value drawn by the axis. If not set explicitly, the axis maximum
1747 * will be calculated automatically.
1755 * The spacing between major intervals on this axis.
1757 * @property majorUnit
1763 * The time unit used by the majorUnit.
1765 * @property majorTimeUnit
1768 majorTimeUnit: null,
1771 * The spacing between minor intervals on this axis.
1773 * @property majorUnit
1779 * The time unit used by the minorUnit.
1781 * @property majorTimeUnit
1784 minorTimeUnit: null,
1787 * If true, the labels, ticks, gridlines, and other objects will snap to
1788 * the nearest major or minor unit. If false, their position will be based
1789 * on the minimum value.
1791 * @property snapToUnits
1797 * Series that are stackable will only stack when this value is set to true.
1799 * @property stackingEnabled
1802 stackingEnabled: false,
1805 * Indicates whether to factor in the size of the labels when calculating a major unit.
1807 * @property calculateByLabelSize
1810 calculateByLabelSize: true
1813 * A type of axis that displays items in categories.
1815 * @namespace YAHOO.widget
1816 * @class CategoryAxis
1819 YAHOO.widget.CategoryAxis = function()
1821 YAHOO.widget.CategoryAxis.superclass.constructor.call(this);
1824 YAHOO.lang.extend(YAHOO.widget.CategoryAxis, YAHOO.widget.Axis,
1829 * A list of category names to display along this axis.
1831 * @property categoryNames
1834 categoryNames: null,
1837 * Indicates whether or not to calculate the number of categories (ticks and labels)
1838 * when there is not enough room to display all labels on the axis. If set to true, the axis
1839 * will determine the number of categories to plot. If not, all categories will be plotted.
1841 * @property calculateCategoryCount
1844 calculateCategoryCount: false
1847 * Functionality common to most series. Generally, a <code>Series</code>
1848 * object shouldn't be instantiated directly. Instead, a subclass with a
1849 * concrete implementation should be used.
1851 * @namespace YAHOO.widget
1855 YAHOO.widget.Series = function() {};
1857 YAHOO.widget.Series.prototype =
1860 * The type of series.
1868 * The human-readable name of the series.
1870 * @property displayName
1877 * Functionality common to most series appearing in cartesian charts.
1878 * Generally, a <code>CartesianSeries</code> object shouldn't be
1879 * instantiated directly. Instead, a subclass with a concrete implementation
1882 * @namespace YAHOO.widget
1883 * @class CartesianSeries
1884 * @uses YAHOO.widget.Series
1887 YAHOO.widget.CartesianSeries = function()
1889 YAHOO.widget.CartesianSeries.superclass.constructor.call(this);
1892 YAHOO.lang.extend(YAHOO.widget.CartesianSeries, YAHOO.widget.Series,
1895 * The field used to access the x-axis value from the items from the data source.
1903 * The field used to access the y-axis value from the items from the data source.
1911 * Indicates which axis the series will bind to
1919 * When a Legend is present, indicates whether the series will show in the legend.
1921 * @property showInLegend
1928 * ColumnSeries class for the YUI Charts widget.
1930 * @namespace YAHOO.widget
1931 * @class ColumnSeries
1932 * @uses YAHOO.widget.CartesianSeries
1935 YAHOO.widget.ColumnSeries = function()
1937 YAHOO.widget.ColumnSeries.superclass.constructor.call(this);
1940 YAHOO.lang.extend(YAHOO.widget.ColumnSeries, YAHOO.widget.CartesianSeries,
1946 * LineSeries class for the YUI Charts widget.
1948 * @namespace YAHOO.widget
1950 * @uses YAHOO.widget.CartesianSeries
1953 YAHOO.widget.LineSeries = function()
1955 YAHOO.widget.LineSeries.superclass.constructor.call(this);
1958 YAHOO.lang.extend(YAHOO.widget.LineSeries, YAHOO.widget.CartesianSeries,
1965 * BarSeries class for the YUI Charts widget.
1967 * @namespace YAHOO.widget
1969 * @uses YAHOO.widget.CartesianSeries
1972 YAHOO.widget.BarSeries = function()
1974 YAHOO.widget.BarSeries.superclass.constructor.call(this);
1977 YAHOO.lang.extend(YAHOO.widget.BarSeries, YAHOO.widget.CartesianSeries,
1984 * PieSeries class for the YUI Charts widget.
1986 * @namespace YAHOO.widget
1988 * @uses YAHOO.widget.Series
1991 YAHOO.widget.PieSeries = function()
1993 YAHOO.widget.PieSeries.superclass.constructor.call(this);
1996 YAHOO.lang.extend(YAHOO.widget.PieSeries, YAHOO.widget.Series,
2001 * The field used to access the data value from the items from the data source.
2003 * @property dataField
2009 * The field used to access the category value from the items from the data source.
2011 * @property categoryField
2014 categoryField: null,
2017 * A string reference to the globally-accessible function that may be called to
2018 * determine each of the label values for this series. Also accepts function references.
2020 * @property labelFunction
2027 * StackedBarSeries class for the YUI Charts widget.
2029 * @namespace YAHOO.widget
2030 * @class StackedBarSeries
2031 * @uses YAHOO.widget.CartesianSeries
2034 YAHOO.widget.StackedBarSeries = function()
2036 YAHOO.widget.StackedBarSeries.superclass.constructor.call(this);
2039 YAHOO.lang.extend(YAHOO.widget.StackedBarSeries, YAHOO.widget.CartesianSeries,
2045 * StackedColumnSeries class for the YUI Charts widget.
2047 * @namespace YAHOO.widget
2048 * @class StackedColumnSeries
2049 * @uses YAHOO.widget.CartesianSeries
2052 YAHOO.widget.StackedColumnSeries = function()
2054 YAHOO.widget.StackedColumnSeries.superclass.constructor.call(this);
2057 YAHOO.lang.extend(YAHOO.widget.StackedColumnSeries, YAHOO.widget.CartesianSeries,
2061 YAHOO.register("charts", YAHOO.widget.Chart, {version: "2.8.0r4", build: "2449"});