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)
575 if(this._seriesFunctions)
577 var count = this._seriesFunctions.length;
578 for(i = 0; i < count; i++)
580 YAHOO.widget.Chart.removeProxyFunction(this._seriesFunctions[i]);
582 this._seriesFunctions = null;
584 this._seriesFunctions = [];
586 //make a copy of the series definitions so that we aren't
587 //editing them directly.
588 var dataProvider = [];
590 var currentSeries = null;
591 if(this._seriesDefs !== null)
593 seriesCount = this._seriesDefs.length;
594 for(i = 0; i < seriesCount; i++)
596 currentSeries = this._seriesDefs[i];
597 var clonedSeries = {};
598 for(var prop in currentSeries)
600 if(YAHOO.lang.hasOwnProperty(currentSeries, prop))
604 if(currentSeries.style !== null)
606 clonedSeries.style = YAHOO.lang.JSON.stringify(currentSeries.style);
610 else if(prop == "labelFunction")
612 if(currentSeries.labelFunction !== null)
614 clonedSeries.labelFunction = YAHOO.widget.Chart.getFunctionReference(currentSeries.labelFunction);
615 this._seriesFunctions.push(clonedSeries.labelFunction);
619 else if(prop == "dataTipFunction")
621 if(currentSeries.dataTipFunction !== null)
623 clonedSeries.dataTipFunction = YAHOO.widget.Chart.getFunctionReference(currentSeries.dataTipFunction);
624 this._seriesFunctions.push(clonedSeries.dataTipFunction);
628 else if(prop == "legendLabelFunction")
630 if(currentSeries.legendLabelFunction !== null)
632 clonedSeries.legendLabelFunction = YAHOO.widget.Chart.getFunctionReference(currentSeries.legendLabelFunction);
633 this._seriesFunctions.push(clonedSeries.legendLabelFunction);
639 clonedSeries[prop] = currentSeries[prop];
643 dataProvider.push(clonedSeries);
649 for(i = 0; i < seriesCount; i++)
651 currentSeries = dataProvider[i];
652 if(!currentSeries.type)
654 currentSeries.type = this._type;
656 currentSeries.dataProvider = response.results;
661 var series = {type: this._type, dataProvider: response.results};
662 dataProvider.push(series);
666 if(this._swf.setDataProvider) this._swf.setDataProvider(dataProvider);
670 this._swf.setDataProvider(dataProvider);
677 * Storage for the request attribute.
685 * Getter for the request attribute.
687 * @method _getRequest
690 _getRequest: function()
692 return this._request;
696 * Setter for the request attribute.
698 * @method _setRequest
701 _setRequest: function(value)
703 this._request = value;
708 * Storage for the dataSource attribute.
710 * @property _dataSource
716 * Getter for the dataSource attribute.
718 * @method _getDataSource
721 _getDataSource: function()
723 return this._dataSource;
727 * Setter for the dataSource attribute.
729 * @method _setDataSource
732 _setDataSource: function(value)
734 this._dataSource = value;
739 * Storage for the series attribute.
741 * @property _seriesDefs
747 * Getter for the series attribute.
749 * @method _getSeriesDefs
752 _getSeriesDefs: function()
754 return this._seriesDefs;
758 * Setter for the series attribute.
760 * @method _setSeriesDefs
763 _setSeriesDefs: function(value)
765 this._seriesDefs = value;
770 * Getter for the categoryNames attribute.
772 * @method _getCategoryNames
775 _getCategoryNames: function()
777 return this._swf.getCategoryNames();
781 * Setter for the categoryNames attribute.
783 * @method _setCategoryNames
786 _setCategoryNames: function(value)
788 this._swf.setCategoryNames(value);
792 * Setter for the dataTipFunction attribute.
794 * @method _setDataTipFunction
797 _setDataTipFunction: function(value)
799 if(this._dataTipFunction)
801 YAHOO.widget.Chart.removeProxyFunction(this._dataTipFunction);
806 this._dataTipFunction = value = YAHOO.widget.Chart.getFunctionReference(value);
808 this._swf.setDataTipFunction(value);
812 * Setter for the legendLabelFunction attribute.
814 * @method _setLegendLabelFunction
817 _setLegendLabelFunction: function(value)
819 if(this._legendLabelFunction)
821 YAHOO.widget.Chart.removeProxyFunction(this._legendLabelFunction);
826 this._legendLabelFunction = value = YAHOO.widget.Chart.getFunctionReference(value);
828 this._swf.setLegendLabelFunction(value);
832 * Getter for the polling attribute.
834 * @method _getPolling
837 _getPolling: function()
839 return this._pollingInterval;
843 * Setter for the polling attribute.
845 * @method _setPolling
848 _setPolling: function(value)
850 this._pollingInterval = value;
855 * The javascript wrapper for the swf object
857 * @property _swfEmbed
864 * The URL of the SWF file.
872 * The ID of the containing DIV.
873 * @property _containerID
880 * A reference to the embedded SWF file.
887 * The id of this instance.
895 * Indicates whether the SWF has been initialized and is ready
896 * to communicate with JavaScript
897 * @property _initialized
904 * The initializing attributes are stored here until the SWF is ready.
905 * @property _attributes
909 _attributes: null, //the intializing attributes
911 set: function(name, value)
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);
920 * Getter for swfURL attribute.
925 _getSWFURL: function()
931 * Getter for altText attribute.
933 * @method _getAltText
936 _getAltText: function()
938 return this._swf.getAltText();
942 * Setter for altText attribute.
944 * @method _setAltText
947 _setAltText: function(value)
949 this._swf.setAltText(value);
954 * The number of proxy functions that have been created.
958 YAHOO.widget.Chart.proxyFunctionCount = 0;
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
965 * @method YAHOO.widget.Chart.createProxyFunction
969 YAHOO.widget.Chart.createProxyFunction = function(func, scope)
971 var scope = scope || null;
972 var index = YAHOO.widget.Chart.proxyFunctionCount;
973 YAHOO.widget.Chart["proxyFunction" + index] = function()
975 return func.apply(scope, arguments);
977 YAHOO.widget.Chart.proxyFunctionCount++;
978 return "YAHOO.widget.Chart.proxyFunction" + index.toString();
982 * Uses YAHOO.widget.Chart.createProxyFunction to return string
983 * reference to a function.
985 * @method YAHOO.widget.Chart.getFunctionReference
989 YAHOO.widget.Chart.getFunctionReference = function(value)
991 if(typeof value == "function")
993 value = YAHOO.widget.Chart.createProxyFunction(value);
995 else if(value.func && typeof value.func == "function")
997 var args = [value.func];
998 if(value.scope && typeof value.scope == "object")
1000 args.push(value.scope);
1002 value = YAHOO.widget.Chart.createProxyFunction.apply(this, args);
1008 * Removes a function created with createProxyFunction()
1010 * @method YAHOO.widget.Chart.removeProxyFunction
1014 YAHOO.widget.Chart.removeProxyFunction = function(funcName)
1017 if(!funcName || funcName.indexOf("YAHOO.widget.Chart.proxyFunction") < 0)
1022 funcName = funcName.substr(26);
1023 YAHOO.widget.Chart[funcName] = null;
1027 * Storage for the dataTipFunction attribute.
1029 * @property Chart.SWFURL
1033 * @default "assets/charts.swf"
1035 YAHOO.widget.Chart.SWFURL = "assets/charts.swf";
1037 * PieChart class for the YUI Charts widget.
1039 * @namespace YAHOO.widget
1041 * @uses YAHOO.widget.Chart
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.
1047 YAHOO.widget.PieChart = function(containerId, dataSource, attributes)
1049 YAHOO.widget.PieChart.superclass.constructor.call(this, "pie", containerId, dataSource, attributes);
1052 YAHOO.lang.extend(YAHOO.widget.PieChart, YAHOO.widget.Chart,
1055 * Initializes the attributes.
1057 * @method _initAttributes
1060 _initAttributes: function(attributes)
1062 YAHOO.widget.PieChart.superclass._initAttributes.call(this, attributes);
1065 * @attribute dataField
1066 * @description The field in each item that corresponds to the data value.
1069 this.setAttributeConfig("dataField",
1071 validator: YAHOO.lang.isString,
1072 method: this._setDataField,
1073 getter: this._getDataField
1077 * @attribute categoryField
1078 * @description The field in each item that corresponds to the category value.
1081 this.setAttributeConfig("categoryField",
1083 validator: YAHOO.lang.isString,
1084 method: this._setCategoryField,
1085 getter: this._getCategoryField
1090 * Getter for the dataField attribute.
1092 * @method _getDataField
1095 _getDataField: function()
1097 return this._swf.getDataField();
1101 * Setter for the dataField attribute.
1103 * @method _setDataField
1106 _setDataField: function(value)
1108 this._swf.setDataField(value);
1112 * Getter for the categoryField attribute.
1114 * @method _getCategoryField
1117 _getCategoryField: function()
1119 return this._swf.getCategoryField();
1123 * Setter for the categoryField attribute.
1125 * @method _setCategoryField
1128 _setCategoryField: function(value)
1130 this._swf.setCategoryField(value);
1134 * CartesianChart class for the YUI Charts widget.
1136 * @namespace YAHOO.widget
1137 * @class CartesianChart
1138 * @uses YAHOO.widget.Chart
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.
1145 YAHOO.widget.CartesianChart = function(type, containerId, dataSource, attributes)
1147 YAHOO.widget.CartesianChart.superclass.constructor.call(this, type, containerId, dataSource, attributes);
1150 YAHOO.lang.extend(YAHOO.widget.CartesianChart, YAHOO.widget.Chart,
1153 * Stores a reference to the xAxis labelFunction created by
1154 * YAHOO.widget.Chart.createProxyFunction()
1155 * @property _xAxisLabelFunctions
1159 _xAxisLabelFunctions: [],
1162 * Stores a reference to the yAxis labelFunctions created by
1163 * YAHOO.widget.Chart.createProxyFunction()
1164 * @property _yAxisLabelFunctions
1168 _yAxisLabelFunctions: [],
1172 //remove proxy functions
1173 this._removeAxisFunctions(this._xAxisLabelFunctions);
1174 this._removeAxisFunctions(this._yAxisLabelFunctions);
1177 YAHOO.widget.CartesianChart.superclass.destroy.call(this);
1181 * Initializes the attributes.
1183 * @method _initAttributes
1186 _initAttributes: function(attributes)
1188 YAHOO.widget.CartesianChart.superclass._initAttributes.call(this, attributes);
1192 * @description The field in each item that corresponds to a value on the x axis.
1195 this.setAttributeConfig("xField",
1197 validator: YAHOO.lang.isString,
1198 method: this._setXField,
1199 getter: this._getXField
1204 * @description The field in each item that corresponds to a value on the x axis.
1207 this.setAttributeConfig("yField",
1209 validator: YAHOO.lang.isString,
1210 method: this._setYField,
1211 getter: this._getYField
1216 * @description A custom configuration for the horizontal x axis.
1219 this.setAttributeConfig("xAxis",
1221 method: this._setXAxis
1226 * @description Custom configurations for the horizontal x axes.
1229 this.setAttributeConfig("xAxes",
1231 method: this._setXAxes
1236 * @description A custom configuration for the vertical y axis.
1239 this.setAttributeConfig("yAxis",
1241 method: this._setYAxis
1246 * @description Custom configurations for the vertical y axes.
1249 this.setAttributeConfig("yAxes",
1251 method: this._setYAxes
1255 * @attribute constrainViewport
1256 * @description Determines whether the viewport is constrained to prevent series data from overflow.
1259 this.setAttributeConfig("constrainViewport",
1261 method: this._setConstrainViewport
1266 * Getter for the xField attribute.
1268 * @method _getXField
1271 _getXField: function()
1273 return this._swf.getHorizontalField();
1277 * Setter for the xField attribute.
1279 * @method _setXField
1282 _setXField: function(value)
1284 this._swf.setHorizontalField(value);
1288 * Getter for the yField attribute.
1290 * @method _getYField
1293 _getYField: function()
1295 return this._swf.getVerticalField();
1299 * Setter for the yField attribute.
1301 * @method _setYField
1304 _setYField: function(value)
1306 this._swf.setVerticalField(value);
1310 * Receives an axis object, creates a proxy function for
1311 * the labelFunction and returns the updated object.
1313 * @method _getClonedAxis
1316 _getClonedAxis: function(value)
1318 var clonedAxis = {};
1319 for(var prop in value)
1321 if(prop == "labelFunction")
1323 if(value.labelFunction && value.labelFunction !== null)
1325 clonedAxis.labelFunction = YAHOO.widget.Chart.getFunctionReference(value.labelFunction);
1330 clonedAxis[prop] = value[prop];
1337 * Removes axis functions contained in an array
1339 * @method _removeAxisFunctions
1342 _removeAxisFunctions: function(axisFunctions)
1344 if(axisFunctions && axisFunctions.length > 0)
1346 var len = axisFunctions.length;
1347 for(var i = 0; i < len; i++)
1349 if(axisFunctions[i] !== null)
1351 YAHOO.widget.Chart.removeProxyFunction(axisFunctions[i]);
1359 * Setter for the xAxis attribute.
1364 _setXAxis: function(value)
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);
1374 * Setter for the xAxes attribute
1379 _setXAxes: function(value)
1381 this._removeAxisFunctions(this._xAxisLabelFunctions);
1382 var len = value.length;
1383 for(var i = 0; i < len; i++)
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]);
1393 * Setter for the yAxis attribute.
1398 _setYAxis: function(value)
1400 this._removeAxisFunctions(this._yAxisLabelFunctions);
1401 value = this._getClonedAxis(value);
1402 this._yAxisLabelFunctions.push(value.labelFunction);
1403 this._swf.setVerticalAxis(value);
1407 * Setter for the yAxes attribute.
1412 _setYAxes: function(value)
1414 this._removeAxisFunctions(this._yAxisLabelFunctions);
1415 var len = value.length;
1416 for(var i = 0; i < len; i++)
1418 value[i] = this._getClonedAxis(value[i]);
1419 if(value[i].labelFunction) this._yAxisLabelFunctions.push(value[i].labelFunction);
1420 this._swf.setVerticalAxis(value[i]);
1425 * Setter for the constrainViewport attribute
1427 * @method _setConstrainViewport
1430 _setConstrainViewport: function(value)
1432 this._swf.setConstrainViewport(value);
1436 * Sets the style object for a single series based on its index
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
1442 setSeriesStylesByIndex:function(index, style)
1444 style = YAHOO.lang.JSON.stringify(style);
1445 if(this._swf && this._swf.setSeriesStylesByIndex) this._swf.setSeriesStylesByIndex(index, style);
1449 * LineChart class for the YUI Charts widget.
1451 * @namespace YAHOO.widget
1453 * @uses YAHOO.widget.CartesianChart
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.
1459 YAHOO.widget.LineChart = function(containerId, dataSource, attributes)
1461 YAHOO.widget.LineChart.superclass.constructor.call(this, "line", containerId, dataSource, attributes);
1464 YAHOO.lang.extend(YAHOO.widget.LineChart, YAHOO.widget.CartesianChart);
1467 * ColumnChart class for the YUI Charts widget.
1469 * @namespace YAHOO.widget
1470 * @class ColumnChart
1471 * @uses YAHOO.widget.CartesianChart
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.
1477 YAHOO.widget.ColumnChart = function(containerId, dataSource, attributes)
1479 YAHOO.widget.ColumnChart.superclass.constructor.call(this, "column", containerId, dataSource, attributes);
1482 YAHOO.lang.extend(YAHOO.widget.ColumnChart, YAHOO.widget.CartesianChart);
1485 * BarChart class for the YUI Charts widget.
1487 * @namespace YAHOO.widget
1489 * @uses YAHOO.widget.CartesianChart
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.
1495 YAHOO.widget.BarChart = function(containerId, dataSource, attributes)
1497 YAHOO.widget.BarChart.superclass.constructor.call(this, "bar", containerId, dataSource, attributes);
1500 YAHOO.lang.extend(YAHOO.widget.BarChart, YAHOO.widget.CartesianChart);
1503 * StackedColumnChart class for the YUI Charts widget.
1505 * @namespace YAHOO.widget
1506 * @class StackedColumnChart
1507 * @uses YAHOO.widget.CartesianChart
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.
1513 YAHOO.widget.StackedColumnChart = function(containerId, dataSource, attributes)
1515 YAHOO.widget.StackedColumnChart.superclass.constructor.call(this, "stackcolumn", containerId, dataSource, attributes);
1518 YAHOO.lang.extend(YAHOO.widget.StackedColumnChart, YAHOO.widget.CartesianChart);
1521 * StackedBarChart class for the YUI Charts widget.
1523 * @namespace YAHOO.widget
1524 * @class StackedBarChart
1525 * @uses YAHOO.widget.CartesianChart
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.
1531 YAHOO.widget.StackedBarChart = function(containerId, dataSource, attributes)
1533 YAHOO.widget.StackedBarChart.superclass.constructor.call(this, "stackbar", containerId, dataSource, attributes);
1536 YAHOO.lang.extend(YAHOO.widget.StackedBarChart, YAHOO.widget.CartesianChart);
1538 * Defines a CartesianChart's vertical or horizontal axis.
1540 * @namespace YAHOO.widget
1544 YAHOO.widget.Axis = function()
1548 YAHOO.widget.Axis.prototype =
1559 * If true, the items on the axis will be drawn in opposite direction.
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.
1570 * @property labelFunction
1573 labelFunction: null,
1576 * The space, in pixels, between labels on an axis.
1578 * @property labelSpacing
1584 * The text that will appear next to the axis to indicate information about the data that it displays.
1592 * A type of axis whose units are measured in numeric values.
1594 * @namespace YAHOO.widget
1595 * @class NumericAxis
1596 * @extends YAHOO.widget.Axis
1599 YAHOO.widget.NumericAxis = function()
1601 YAHOO.widget.NumericAxis.superclass.constructor.call(this);
1604 YAHOO.lang.extend(YAHOO.widget.NumericAxis, YAHOO.widget.Axis,
1609 * The minimum value drawn by the axis. If not set explicitly, the axis minimum
1610 * will be calculated automatically.
1618 * The maximum value drawn by the axis. If not set explicitly, the axis maximum
1619 * will be calculated automatically.
1627 * The spacing between major intervals on this axis.
1629 * @property majorUnit
1635 * The spacing between minor intervals on this axis.
1637 * @property minorUnit
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.
1647 * @property snapToUnits
1653 * Series that are stackable will only stack when this value is set to true.
1655 * @property stackingEnabled
1658 stackingEnabled: false,
1661 * If true, and the bounds are calculated automatically, either the minimum or
1662 * maximum will be set to zero.
1664 * @property alwaysShowZero
1667 alwaysShowZero: true,
1670 * The scaling algorithm to use on this axis. May be "linear" or "logarithmic".
1678 * Indicates whether to round the major unit.
1680 * @property roundMajorUnit
1683 roundMajorUnit: true,
1686 * Indicates whether to factor in the size of the labels when calculating a major unit.
1688 * @property calculateByLabelSize
1691 calculateByLabelSize: true,
1694 * Indicates the position of the axis relative to the chart
1696 * @property position
1702 * Indicates whether to extend maximum beyond data's maximum to the nearest
1705 * @property adjustMaximumByMajorUnit
1708 adjustMaximumByMajorUnit:true,
1711 * Indicates whether to extend the minimum beyond data's minimum to the nearest
1714 * @property adjustMinimumByMajorUnit
1717 adjustMinimumByMajorUnit:true
1720 * A type of axis whose units are measured in time-based values.
1722 * @namespace YAHOO.widget
1726 YAHOO.widget.TimeAxis = function()
1728 YAHOO.widget.TimeAxis.superclass.constructor.call(this);
1731 YAHOO.lang.extend(YAHOO.widget.TimeAxis, YAHOO.widget.Axis,
1736 * The minimum value drawn by the axis. If not set explicitly, the axis minimum
1737 * will be calculated automatically.
1745 * The maximum value drawn by the axis. If not set explicitly, the axis maximum
1746 * will be calculated automatically.
1754 * The spacing between major intervals on this axis.
1756 * @property majorUnit
1762 * The time unit used by the majorUnit.
1764 * @property majorTimeUnit
1767 majorTimeUnit: null,
1770 * The spacing between minor intervals on this axis.
1772 * @property majorUnit
1778 * The time unit used by the minorUnit.
1780 * @property majorTimeUnit
1783 minorTimeUnit: null,
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.
1790 * @property snapToUnits
1796 * Series that are stackable will only stack when this value is set to true.
1798 * @property stackingEnabled
1801 stackingEnabled: false,
1804 * Indicates whether to factor in the size of the labels when calculating a major unit.
1806 * @property calculateByLabelSize
1809 calculateByLabelSize: true
1812 * A type of axis that displays items in categories.
1814 * @namespace YAHOO.widget
1815 * @class CategoryAxis
1818 YAHOO.widget.CategoryAxis = function()
1820 YAHOO.widget.CategoryAxis.superclass.constructor.call(this);
1823 YAHOO.lang.extend(YAHOO.widget.CategoryAxis, YAHOO.widget.Axis,
1828 * A list of category names to display along this axis.
1830 * @property categoryNames
1833 categoryNames: null,
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.
1840 * @property calculateCategoryCount
1843 calculateCategoryCount: false
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.
1850 * @namespace YAHOO.widget
1854 YAHOO.widget.Series = function() {};
1856 YAHOO.widget.Series.prototype =
1859 * The type of series.
1867 * The human-readable name of the series.
1869 * @property displayName
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
1881 * @namespace YAHOO.widget
1882 * @class CartesianSeries
1883 * @uses YAHOO.widget.Series
1886 YAHOO.widget.CartesianSeries = function()
1888 YAHOO.widget.CartesianSeries.superclass.constructor.call(this);
1891 YAHOO.lang.extend(YAHOO.widget.CartesianSeries, YAHOO.widget.Series,
1894 * The field used to access the x-axis value from the items from the data source.
1902 * The field used to access the y-axis value from the items from the data source.
1910 * Indicates which axis the series will bind to
1918 * When a Legend is present, indicates whether the series will show in the legend.
1920 * @property showInLegend
1927 * ColumnSeries class for the YUI Charts widget.
1929 * @namespace YAHOO.widget
1930 * @class ColumnSeries
1931 * @uses YAHOO.widget.CartesianSeries
1934 YAHOO.widget.ColumnSeries = function()
1936 YAHOO.widget.ColumnSeries.superclass.constructor.call(this);
1939 YAHOO.lang.extend(YAHOO.widget.ColumnSeries, YAHOO.widget.CartesianSeries,
1945 * LineSeries class for the YUI Charts widget.
1947 * @namespace YAHOO.widget
1949 * @uses YAHOO.widget.CartesianSeries
1952 YAHOO.widget.LineSeries = function()
1954 YAHOO.widget.LineSeries.superclass.constructor.call(this);
1957 YAHOO.lang.extend(YAHOO.widget.LineSeries, YAHOO.widget.CartesianSeries,
1964 * BarSeries class for the YUI Charts widget.
1966 * @namespace YAHOO.widget
1968 * @uses YAHOO.widget.CartesianSeries
1971 YAHOO.widget.BarSeries = function()
1973 YAHOO.widget.BarSeries.superclass.constructor.call(this);
1976 YAHOO.lang.extend(YAHOO.widget.BarSeries, YAHOO.widget.CartesianSeries,
1983 * PieSeries class for the YUI Charts widget.
1985 * @namespace YAHOO.widget
1987 * @uses YAHOO.widget.Series
1990 YAHOO.widget.PieSeries = function()
1992 YAHOO.widget.PieSeries.superclass.constructor.call(this);
1995 YAHOO.lang.extend(YAHOO.widget.PieSeries, YAHOO.widget.Series,
2000 * The field used to access the data value from the items from the data source.
2002 * @property dataField
2008 * The field used to access the category value from the items from the data source.
2010 * @property categoryField
2013 categoryField: null,
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.
2019 * @property labelFunction
2026 * StackedBarSeries class for the YUI Charts widget.
2028 * @namespace YAHOO.widget
2029 * @class StackedBarSeries
2030 * @uses YAHOO.widget.CartesianSeries
2033 YAHOO.widget.StackedBarSeries = function()
2035 YAHOO.widget.StackedBarSeries.superclass.constructor.call(this);
2038 YAHOO.lang.extend(YAHOO.widget.StackedBarSeries, YAHOO.widget.CartesianSeries,
2044 * StackedColumnSeries class for the YUI Charts widget.
2046 * @namespace YAHOO.widget
2047 * @class StackedColumnSeries
2048 * @uses YAHOO.widget.CartesianSeries
2051 YAHOO.widget.StackedColumnSeries = function()
2053 YAHOO.widget.StackedColumnSeries.superclass.constructor.call(this);
2056 YAHOO.lang.extend(YAHOO.widget.StackedColumnSeries, YAHOO.widget.CartesianSeries,
2060 YAHOO.register("charts", YAHOO.widget.Chart, {version: "2.8.0r4", build: "2449"});