# Yahoo! UI Library

### charts 3.3.0

Yahoo! UI Library > charts > StackedAxis.js (source view)
Search:
Filters Show Private Show Protected Show Deprecated

    /**
     * StackedAxis manages stacked numeric data on an axis.
     *
     * @param {Object} config (optional) Configuration parameters for the Chart.
     * @class StackedAxis
     * @constructor
     * @extends NumericAxis
     */
    function StackedAxis(config)
    {
    	StackedAxis.superclass.constructor.apply(this, arguments);
    }

    StackedAxis.NAME = "stackedAxis";

    Y.extend(StackedAxis, Y.NumericAxis,
    {
        /**
         * @private
         */
        _updateMinAndMax: function()
        {
            var max = 0,
                min = 0,
                pos = 0,
                neg = 0,
                len = 0,
                i = 0,
                key,
                num,
                keys = this.get("keys");

            for(key in keys)
            {
                if(keys.hasOwnProperty(key))
                {
                    len = Math.max(len, keys[key].length);
                }
            }
            for(; i < len; ++i)
            {
                pos = 0;
                neg = 0;
                for(key in keys)
                {
                    if(keys.hasOwnProperty(key))
                    {
                        num = keys[key][i];
                        if(isNaN(num))
                        {
                            continue;
                        }
                        if(num >= 0)
                        {
                            pos += num;
                        }
                        else
                        {
                            neg += num;
                        }
                    }
                }
                if(pos > 0)
                {
                    max = Math.max(max, pos);
                }
                else
                {
                    max = Math.max(max, neg);
                }
                if(neg < 0)
                {
                    min = Math.min(min, neg);
                }
                else
                {
                    min = Math.min(min, pos);
                }
            }
            this._roundMinAndMax(min, max);
        }
    });

    Y.StackedAxis = StackedAxis;

Copyright © 2011 Yahoo! Inc. All rights reserved.