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