[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/yuilib/3.17.2/series-range/ -> series-range-debug.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('series-range', function (Y, NAME) {
   9  
  10  /**
  11   * Provides functionality for creating a range series.
  12   *
  13   * @module charts
  14   * @submodule series-range
  15   */
  16  
  17  /**
  18   * An abstract class for creating range series instances.
  19   * RangeSeries is used by the following classes:
  20   * <ul>
  21   *      <li>{{#crossLink "CandlestickSeries"}}{{/crossLink}}</li>
  22   *      <li>{{#crossLink "OHLCSeries"}}{{/crossLink}}</li>
  23   *  </ul>
  24   *
  25   * @class RangeSeries
  26   * @extends CartesianSeries
  27   * @constructor
  28   * @param {Object} config (optional) Configuration parameters.
  29   * @submodule series-range
  30   */
  31  function RangeSeries()
  32  {
  33      RangeSeries.superclass.constructor.apply(this, arguments);
  34  }
  35  
  36  RangeSeries.NAME = "rangeSeries";
  37  
  38  RangeSeries.ATTRS = {
  39      /**
  40       * Read-only attribute indicating the type of series.
  41       *
  42       * @attribute type
  43       * @type String
  44       * @default range
  45       */
  46      type: {
  47          value: "range"
  48      },
  49  
  50      /**
  51       * Values to be used for open, high, low and close keys.
  52       *
  53       * @attribute ohlc
  54       * @type Object
  55       */
  56      ohlckeys: {
  57          valueFn: function() {
  58              return {
  59                  open: "open",
  60                  high: "high",
  61                  low: "low",
  62                  close: "close"
  63              };
  64          }
  65      }
  66  };
  67  
  68  Y.extend(RangeSeries, Y.CartesianSeries, {
  69      /**
  70       * Returns the width for each marker base on the width of the series
  71       * and the length of the dataProvider.
  72       *
  73       * @method calculateMarkerWidth
  74       * @param {Number} width The width, in pixels of the series.
  75       * @param {Number} count The length of the datProvider.
  76       * @return Number
  77       * @private
  78       */
  79      _calculateMarkerWidth: function(width, count, spacing)
  80      {
  81          var val = 0;
  82          while(val < 3 && spacing > -1)
  83          {
  84              spacing = spacing - 1;
  85              val = Math.round(width/count - spacing);
  86              if(val % 2 === 0) {
  87                  val = val - 1;
  88              }
  89          }
  90          return Math.max(1, val);
  91      },
  92  
  93      /**
  94       * Draws the series.
  95       *
  96       * @method drawSeries
  97       * @protected
  98       */
  99      drawSeries: function()
 100      {
 101          var xcoords = this.get("xcoords"),
 102              ycoords = this.get("ycoords"),
 103              styles = this.get("styles"),
 104              padding = styles.padding,
 105              len = xcoords.length,
 106              dataWidth = this.get("width") - (padding.left + padding.right),
 107              keys = this.get("ohlckeys"),
 108              opencoords = ycoords[keys.open],
 109              highcoords = ycoords[keys.high],
 110              lowcoords = ycoords[keys.low],
 111              closecoords = ycoords[keys.close],
 112              width = this._calculateMarkerWidth(dataWidth, len, styles.spacing),
 113              halfwidth = width/2;
 114          this._drawMarkers(xcoords, opencoords, highcoords, lowcoords, closecoords, len, width, halfwidth, styles);
 115      },
 116  
 117      /**
 118       * Gets the default value for the `styles` attribute. Overrides
 119       * base implementation.
 120       *
 121       * @method _getDefaultStyles
 122       * @return Object
 123       * @private
 124       */
 125      _getDefaultStyles: function()
 126      {
 127          var styles = {
 128              spacing: 3
 129          };
 130          return this._mergeStyles(styles, RangeSeries.superclass._getDefaultStyles());
 131      }
 132  });
 133  
 134  Y.RangeSeries = RangeSeries;
 135  
 136  
 137  
 138  
 139  }, '3.17.2', {"requires": ["series-cartesian"]});


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