[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/yuilib/3.17.2/axis-category/ -> axis-category.js (source)

   1  /*
   2  YUI 3.17.2 (build 9c3c78e)
   3  Copyright 2014 Yahoo! Inc. All rights reserved.
   4  Licensed under the BSD License.
   5  http://yuilibrary.com/license/
   6  */
   7  
   8  YUI.add('axis-category', function (Y, NAME) {
   9  
  10  /**
  11   * Provides functionality for drawing a category axis for use with a chart.
  12   *
  13   * @module charts
  14   * @submodule axis-category
  15   */
  16  var Y_Lang = Y.Lang;
  17  /**
  18   * CategoryAxis draws a category axis for a chart.
  19   *
  20   * @class CategoryAxis
  21   * @constructor
  22   * @extends Axis
  23   * @uses CategoryImpl
  24   * @param {Object} config (optional) Configuration parameters.
  25   * @submodule axis-category
  26   */
  27  Y.CategoryAxis = Y.Base.create("categoryAxis", Y.Axis, [Y.CategoryImpl], {
  28      /**
  29       * Returns a string corresponding to the first label on an
  30       * axis.
  31       *
  32       * @method getMinimumValue
  33       * @return String
  34       */
  35      getMinimumValue: function()
  36      {
  37          var data = this.get("data"),
  38              label = data[0];
  39          return label;
  40      },
  41  
  42      /**
  43       * Returns a string corresponding to the last label on an
  44       * axis.
  45       *
  46       * @method getMaximumValue
  47       * @return String
  48       */
  49      getMaximumValue: function()
  50      {
  51          var data = this.get("data"),
  52              len = data.length - 1,
  53              label = data[len];
  54          return label;
  55      },
  56  
  57      /**
  58       * Calculates and returns a value based on the number of labels and the index of
  59       * the current label.
  60       *
  61       * @method _getLabelByIndex
  62       * @param {Number} i Index of the label.
  63       * @return String
  64       * @private
  65       */
  66      _getLabelByIndex: function(i)
  67      {
  68          var label,
  69              data = this.get("data");
  70          label = data[i];
  71          return label;
  72      },
  73  
  74      /**
  75       * Returns an object literal containing and array of label values and an array of points.
  76       *
  77       * @method _getLabelData
  78       * @param {Object} startPoint An object containing x and y values.
  79       * @param {Number} edgeOffset Distance to offset coordinates.
  80       * @param {Number} layoutLength Distance that the axis spans.
  81       * @param {Number} count Number of labels.
  82       * @param {String} direction Indicates whether the axis is horizontal or vertical.
  83       * @param {Array} Array containing values for axis labels.
  84       * @return Array
  85       * @private
  86       */
  87      _getLabelData: function(constantVal, staticCoord, dynamicCoord, min, max, edgeOffset, layoutLength, count, dataValues)
  88      {
  89          var labelValue,
  90              i,
  91              points = [],
  92              values = [],
  93              point,
  94              labelIndex,
  95              data = this.get("data"),
  96              offset = edgeOffset;
  97          dataValues = dataValues || data;
  98          for(i = 0; i < count; i = i + 1)
  99          {
 100              labelValue = dataValues[i];
 101              labelIndex = Y.Array.indexOf(data, labelValue);
 102              if(Y_Lang.isNumber(labelIndex) && labelIndex > -1)
 103              {
 104                  point = {};
 105                  point[staticCoord] = constantVal;
 106                  point[dynamicCoord] = this._getCoordFromValue(
 107                      min,
 108                      max,
 109                      layoutLength,
 110                      labelIndex,
 111                      offset
 112                  );
 113                  points.push(point);
 114                  values.push(labelValue);
 115              }
 116          }
 117          return {
 118              points: points,
 119              values: values
 120          };
 121      }
 122  });
 123  
 124  
 125  
 126  }, '3.17.2', {"requires": ["axis", "axis-category-base"]});


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1