src/cm/media/js/lib/yui/yui3-3.15.0/build/series-column/series-column-debug.js
changeset 602 e16a97fb364a
equal deleted inserted replaced
601:d334a616c023 602:e16a97fb364a
       
     1 YUI.add('series-column', function (Y, NAME) {
       
     2 
       
     3 /**
       
     4  * Provides functionality for creating a column series.
       
     5  *
       
     6  * @module charts
       
     7  * @submodule series-column
       
     8  */
       
     9 /**
       
    10  * The ColumnSeries class renders columns positioned horizontally along a category or time axis. The columns'
       
    11  * lengths are proportional to the values they represent along a vertical axis.
       
    12  * and the relevant data points.
       
    13  *
       
    14  * @class ColumnSeries
       
    15  * @extends MarkerSeries
       
    16  * @uses Histogram
       
    17  * @constructor
       
    18  * @param {Object} config (optional) Configuration parameters.
       
    19  * @submodule series-column
       
    20  */
       
    21 Y.ColumnSeries = Y.Base.create("columnSeries", Y.MarkerSeries, [Y.Histogram], {
       
    22     /**
       
    23      * Helper method for calculating the size of markers.
       
    24      *
       
    25      * @method _getMarkerDimensions
       
    26      * @param {Number} xcoord The x-coordinate representing the data point for the marker.
       
    27      * @param {Number} ycoord The y-coordinate representing the data point for the marker.
       
    28      * @param {Number} calculatedSize The calculated size for the marker. For a `BarSeries` is it the width. For a `ColumnSeries` it is the height.
       
    29      * @param {Number} offset Distance of position offset dictated by other marker series in the same graph.
       
    30      * @return Object
       
    31      * @private
       
    32      */
       
    33     _getMarkerDimensions: function(xcoord, ycoord, calculatedSize, offset)
       
    34     {
       
    35         var config = {
       
    36             left: xcoord + offset
       
    37         };
       
    38         if(this._bottomOrigin >= ycoord)
       
    39         {
       
    40             config.top = ycoord;
       
    41             config.calculatedSize = this._bottomOrigin - config.top;
       
    42         }
       
    43         else
       
    44         {
       
    45             config.top = this._bottomOrigin;
       
    46             config.calculatedSize = ycoord - this._bottomOrigin;
       
    47         }
       
    48         return config;
       
    49     },
       
    50 
       
    51     /**
       
    52      * Resizes and positions markers based on a mouse interaction.
       
    53      *
       
    54      * @method updateMarkerState
       
    55      * @param {String} type state of the marker
       
    56      * @param {Number} i index of the marker
       
    57      * @protected
       
    58      */
       
    59     updateMarkerState: function(type, i)
       
    60     {
       
    61         if(this._markers && this._markers[i])
       
    62         {
       
    63             var styles = this._copyObject(this.get("styles").marker),
       
    64                 markerStyles,
       
    65                 state = this._getState(type),
       
    66                 xcoords = this.get("xcoords"),
       
    67                 ycoords = this.get("ycoords"),
       
    68                 marker = this._markers[i],
       
    69                 markers,
       
    70                 seriesStyles,
       
    71                 seriesCollection = this.get("seriesTypeCollection"),
       
    72                 seriesLen = seriesCollection ? seriesCollection.length : 0,
       
    73                 seriesSize = 0,
       
    74                 offset = 0,
       
    75                 renderer,
       
    76                 n = 0,
       
    77                 xs = [],
       
    78                 order = this.get("order"),
       
    79                 config;
       
    80             markerStyles = state === "off" || !styles[state] ? this._copyObject(styles) : this._copyObject(styles[state]);
       
    81             markerStyles.fill.color = this._getItemColor(markerStyles.fill.color, i);
       
    82             markerStyles.border.color = this._getItemColor(markerStyles.border.color, i);
       
    83             config = this._getMarkerDimensions(xcoords[i], ycoords[i], styles.width, offset);
       
    84             markerStyles.height = config.calculatedSize;
       
    85             markerStyles.width = Math.min(this._maxSize, markerStyles.width);
       
    86             marker.set(markerStyles);
       
    87             for(; n < seriesLen; ++n)
       
    88             {
       
    89                 xs[n] = xcoords[i] + seriesSize;
       
    90                 seriesStyles = seriesCollection[n].get("styles").marker;
       
    91                 seriesSize += Math.min(this._maxSize, seriesStyles.width);
       
    92                 if(order > n)
       
    93                 {
       
    94                     offset = seriesSize;
       
    95                 }
       
    96                 offset -= seriesSize/2;
       
    97             }
       
    98             for(n = 0; n < seriesLen; ++n)
       
    99             {
       
   100                 markers = seriesCollection[n].get("markers");
       
   101                 if(markers)
       
   102                 {
       
   103                     renderer = markers[i];
       
   104                     if(renderer && renderer !== undefined)
       
   105                     {
       
   106                         renderer.set("x", (xs[n] - seriesSize/2));
       
   107                     }
       
   108                 }
       
   109             }
       
   110         }
       
   111     }
       
   112 }, {
       
   113     ATTRS: {
       
   114         /**
       
   115          * Read-only attribute indicating the type of series.
       
   116          *
       
   117          * @attribute type
       
   118          * @type String
       
   119          * @readOnly
       
   120          * @default column
       
   121          */
       
   122         type: {
       
   123             value: "column"
       
   124         }
       
   125 
       
   126         /**
       
   127          * Style properties used for drawing markers. This attribute is inherited from `MarkerSeries`. Below are the default values:
       
   128          *  <dl>
       
   129          *      <dt>fill</dt><dd>A hash containing the following values:
       
   130          *          <dl>
       
   131          *              <dt>color</dt><dd>Color of the fill. The default value is determined by the order of the series on the graph. The color
       
   132          *              will be retrieved from the below array:<br/>
       
   133          *              `["#66007f", "#a86f41", "#295454", "#996ab2", "#e8cdb7", "#90bdbd","#000000","#c3b8ca", "#968373", "#678585"]`
       
   134          *              </dd>
       
   135          *              <dt>alpha</dt><dd>Number from 0 to 1 indicating the opacity of the marker fill. The default value is 1.</dd>
       
   136          *          </dl>
       
   137          *      </dd>
       
   138          *      <dt>border</dt><dd>A hash containing the following values:
       
   139          *          <dl>
       
   140          *              <dt>color</dt><dd>Color of the border. The default value is determined by the order of the series on the graph. The color
       
   141          *              will be retrieved from the below array:<br/>
       
   142          *              `["#205096", "#b38206", "#000000", "#94001e", "#9d6fa0", "#e55b00", "#5e85c9", "#adab9e", "#6ac291", "#006457"]`
       
   143          *              <dt>alpha</dt><dd>Number from 0 to 1 indicating the opacity of the marker border. The default value is 1.</dd>
       
   144          *              <dt>weight</dt><dd>Number indicating the width of the border. The default value is 1.</dd>
       
   145          *          </dl>
       
   146          *      </dd>
       
   147          *      <dt>width</dt><dd>indicates the width of the marker. The default value is 12.</dd>
       
   148          *      <dt>over</dt><dd>hash containing styles for markers when highlighted by a `mouseover` event. The default
       
   149          *      values for each style is null. When an over style is not set, the non-over value will be used. For example,
       
   150          *      the default value for `marker.over.fill.color` is equivalent to `marker.fill.color`.</dd>
       
   151          *  </dl>
       
   152          *
       
   153          * @attribute styles
       
   154          * @type Object
       
   155          */
       
   156     }
       
   157 });
       
   158 
       
   159 
       
   160 }, '@VERSION@', {"requires": ["series-marker", "series-histogram-base"]});