src/cm/media/js/lib/yui/yui_3.10.3/build/axis-stacked-base/axis-stacked-base-debug.js
changeset 525 89ef5ed3c48b
equal deleted inserted replaced
524:322d0feea350 525:89ef5ed3c48b
       
     1 /*
       
     2 YUI 3.10.3 (build 2fb5187)
       
     3 Copyright 2013 Yahoo! Inc. All rights reserved.
       
     4 Licensed under the BSD License.
       
     5 http://yuilibrary.com/license/
       
     6 */
       
     7 
       
     8 YUI.add('axis-stacked-base', function (Y, NAME) {
       
     9 
       
    10 /**
       
    11  * Provides core functionality for the handling of stacked numeric axis data for a chart.
       
    12  *
       
    13  * @module charts
       
    14  * @submodule axis-stacked-base
       
    15  */
       
    16 
       
    17 /**
       
    18  * StackedImpl contains logic for managing stacked numeric data. StackedImpl is used by the following classes:
       
    19  * <ul>
       
    20  *      <li>{{#crossLink "StackedAxisBase"}}{{/crossLink}}</li>
       
    21  *      <li>{{#crossLink "StackedAxis"}}{{/crossLink}}</li>
       
    22  *  </ul>
       
    23  *
       
    24  * @submodule axis-stacked-base
       
    25  * @class StackedImpl
       
    26  * @constructor
       
    27  */
       
    28 function StackedImpl()
       
    29 {
       
    30 }
       
    31 
       
    32 StackedImpl.NAME = "stackedImpl";
       
    33 
       
    34 StackedImpl.prototype = {
       
    35     /**
       
    36      * Type of data used in `Data`.
       
    37      *
       
    38      * @property _type
       
    39      * @readOnly
       
    40      * @private
       
    41      */
       
    42     _type: "stacked",
       
    43 
       
    44     /**
       
    45      * Calculates the maximum and minimum values for the `Data`.
       
    46      *
       
    47      * @method _updateMinAndMax
       
    48      * @private
       
    49      */
       
    50     _updateMinAndMax: function()
       
    51     {
       
    52         var max = 0,
       
    53             min = 0,
       
    54             pos = 0,
       
    55             neg = 0,
       
    56             len = 0,
       
    57             i = 0,
       
    58             key,
       
    59             num,
       
    60             keys = this.get("keys"),
       
    61             setMin = this.get("setMin"),
       
    62             setMax = this.get("setMax");
       
    63 
       
    64         for(key in keys)
       
    65         {
       
    66             if(keys.hasOwnProperty(key))
       
    67             {
       
    68                 len = Math.max(len, keys[key].length);
       
    69             }
       
    70         }
       
    71         for(; i < len; ++i)
       
    72         {
       
    73             pos = 0;
       
    74             neg = 0;
       
    75             for(key in keys)
       
    76             {
       
    77                 if(keys.hasOwnProperty(key))
       
    78                 {
       
    79                     num = keys[key][i];
       
    80                     if(isNaN(num))
       
    81                     {
       
    82                         continue;
       
    83                     }
       
    84                     if(num >= 0)
       
    85                     {
       
    86                         pos += num;
       
    87                     }
       
    88                     else
       
    89                     {
       
    90                         neg += num;
       
    91                     }
       
    92                 }
       
    93             }
       
    94             if(pos > 0)
       
    95             {
       
    96                 max = Math.max(max, pos);
       
    97             }
       
    98             else
       
    99             {
       
   100                 max = Math.max(max, neg);
       
   101             }
       
   102             if(neg < 0)
       
   103             {
       
   104                 min = Math.min(min, neg);
       
   105             }
       
   106             else
       
   107             {
       
   108                 min = Math.min(min, pos);
       
   109             }
       
   110         }
       
   111         this._actualMaximum = max;
       
   112         this._actualMinimum = min;
       
   113         if(setMax)
       
   114         {
       
   115             max = this._setMaximum;
       
   116         }
       
   117         if(setMin)
       
   118         {
       
   119             min = this._setMinimum;
       
   120         }
       
   121         this._roundMinAndMax(min, max, setMin, setMax);
       
   122     }
       
   123 };
       
   124 
       
   125 Y.StackedImpl = StackedImpl;
       
   126 
       
   127 /**
       
   128  * StackedAxisBase manages stacked numeric data for an axis.
       
   129  *
       
   130  * @class StackedAxisBase
       
   131  * @constructor
       
   132  * @extends AxisBase
       
   133  * @uses StackedImpl
       
   134  * @param {Object} config (optional) Configuration parameters.
       
   135  * @submodule axis-stacked-base
       
   136  */
       
   137 Y.StackedAxisBase = Y.Base.create("stackedAxisBase", Y.NumericAxisBase, [Y.StackedImpl]);
       
   138 
       
   139 
       
   140 }, '3.10.3', {"requires": ["axis-numeric-base"]});