src/cm/media/js/lib/yui/yui_3.10.3/build/series-ohlc/series-ohlc-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('series-ohlc', function (Y, NAME) {
       
     9 
       
    10 /**
       
    11  * Provides functionality for creating a ohlc series.
       
    12  *
       
    13  * @module charts
       
    14  * @submodule series-ohlc
       
    15  */
       
    16 /**
       
    17  * The OHLCSeries class renders lines representing the open, high, low and close
       
    18  * values for a chart.
       
    19  *
       
    20  * @class OHLCSeries
       
    21  * @extends RangeSeries
       
    22  * @constructor
       
    23  * @param {Object} config (optional) Configuration parameters.
       
    24  * @submodule series-ohlc
       
    25  */
       
    26 function OHLCSeries()
       
    27 {
       
    28     OHLCSeries.superclass.constructor.apply(this, arguments);
       
    29 }
       
    30 
       
    31 OHLCSeries.NAME = "ohlcSeries";
       
    32 
       
    33 OHLCSeries.ATTRS = {
       
    34     /**
       
    35      * Read-only attribute indicating the type of series.
       
    36      *
       
    37      * @attribute type
       
    38      * @type String
       
    39      * @readOnly
       
    40      * @default ohlc
       
    41      */
       
    42     type: {
       
    43         value: "ohlc"
       
    44     },
       
    45 
       
    46     /**
       
    47      * The graphic in which drawings will be rendered.
       
    48      *
       
    49      * @attribute graphic
       
    50      * @type Graphic
       
    51      */
       
    52     graphic: {
       
    53         lazyAdd: false,
       
    54 
       
    55         setter: function(val) {
       
    56             //woraround for Attribute order of operations bug
       
    57             if(!this.get("rendered")) {
       
    58                 this.set("rendered", true);
       
    59             }
       
    60             this.set("upmarker", val.addShape({
       
    61                type: "path"
       
    62             }));
       
    63             this.set("downmarker", val.addShape({
       
    64                type: "path"
       
    65             }));
       
    66             return val;
       
    67         }
       
    68     },
       
    69 
       
    70     upmarker: {},
       
    71 
       
    72     downmarker: {}
       
    73 
       
    74     /**
       
    75      * Style properties used for drawing markers. This attribute is inherited from `RangeSeries`. Below are the default values:
       
    76      *  <dl>
       
    77      *      <dt>upmarker</dt><dd>Properties for a marker representing a period that closes higher than it opens.
       
    78      *          <dl>
       
    79      *              <dt>fill</dt><dd>A hash containing the following values:
       
    80      *                  <dl>
       
    81      *                      <dt>color</dt><dd>Color of the fill. The default value is "#00aa00".</dd>
       
    82      *                      </dd>
       
    83      *                      <dt>alpha</dt><dd>Number from 0 to 1 indicating the opacity of the marker fill. The default value is 1.</dd>
       
    84      *                  </dl>
       
    85      *              </dd>
       
    86      *              <dt>border</dt><dd>A hash containing the following values:
       
    87      *                  <dl>
       
    88      *                      <dt>color</dt><dd>Color of the border. The default value is "#000000".</dd>
       
    89      *                      <dt>alpha</dt><dd>Number from 0 to 1 indicating the opacity of the marker border. The default value is 1.</dd>
       
    90      *                      <dt>weight</dt><dd>Number indicating the width of the border. The default value is 0.</dd>
       
    91      *                  </dl>
       
    92      *              </dd>
       
    93      *          </dl>
       
    94      *      </dd>
       
    95      *      <dt>downmarker</dt><dd>Properties for a marker representing a period that opens higher than it closes.
       
    96      *          <dl>
       
    97      *              <dt>fill</dt><dd>A hash containing the following values:
       
    98      *                  <dl>
       
    99      *                      <dt>color</dt><dd>Color of the fill. The default value is "#aa0000".</dd>
       
   100      *                      </dd>
       
   101      *                      <dt>alpha</dt><dd>Number from 0 to 1 indicating the opacity of the marker fill. The default value is 1.</dd>
       
   102      *                  </dl>
       
   103      *              </dd>
       
   104      *              <dt>border</dt><dd>A hash containing the following values:
       
   105      *                  <dl>
       
   106      *                      <dt>color</dt><dd>Color of the border. The default value is "#000000".</dd>
       
   107      *                      <dt>alpha</dt><dd>Number from 0 to 1 indicating the opacity of the marker border. The default value is 1.</dd>
       
   108      *                      <dt>weight</dt><dd>Number indicating the width of the border. The default value is 0.</dd>
       
   109      *                  </dl>
       
   110      *              </dd>
       
   111      *          </dl>
       
   112      *      </dd>
       
   113      *  </dl>
       
   114      *
       
   115      * @attribute styles
       
   116      * @type Object
       
   117      */
       
   118 };
       
   119 
       
   120 Y.extend(OHLCSeries, Y.RangeSeries, {
       
   121     /**
       
   122      * Draws markers for an OHLC series.
       
   123      *
       
   124      * @method
       
   125      * @param {Array} xcoords The xcoordinates to be plotted.
       
   126      * @param {Array} opencoords The coordinates representing the open values.
       
   127      * @param {Array} highcoords The coordinates representing the high values.
       
   128      * @param {Array} lowcoords The coordinates representing the low values.
       
   129      * @param {Array} closecoords The coordinates representing the close values.
       
   130      * @param {Number} len The number of x coordinates to plot.
       
   131      * @param {Number} width The width of each ohlc marker.
       
   132      * @param {Number} halfwidth Half the width of each ohlc marker.
       
   133      * @param {Object} styles The styles for the series.
       
   134      * @private
       
   135      */
       
   136     _drawMarkers: function(xcoords, opencoords, highcoords, lowcoords, closecoords, len, width, halfwidth, styles)
       
   137     {
       
   138         var upmarker = this.get("upmarker"),
       
   139             downmarker = this.get("downmarker"),
       
   140             opencoord,
       
   141             highcoord,
       
   142             lowcoord,
       
   143             closecoord,
       
   144             left,
       
   145             right,
       
   146             leftPadding = styles.padding.left,
       
   147             marker,
       
   148             up;
       
   149         upmarker.set(styles.upmarker);
       
   150         downmarker.set(styles.downmarker);
       
   151         upmarker.clear();
       
   152         downmarker.clear();
       
   153         for(i = 0; i < len; i = i + 1)
       
   154         {
       
   155             cx = xcoords[i] + leftPadding;
       
   156             left = cx - halfwidth;
       
   157             right = cx + halfwidth;
       
   158             opencoord = opencoords[i];
       
   159             highcoord = highcoords[i];
       
   160             lowcoord = lowcoords[i];
       
   161             closecoord = closecoords[i];
       
   162             up = opencoord > closecoord;
       
   163             height = lowcoord - highcoord;
       
   164             marker = up ? upmarker : downmarker;
       
   165             marker.moveTo(left, opencoord);
       
   166             marker.lineTo(cx, opencoord);
       
   167             marker.moveTo(cx, highcoord);
       
   168             marker.lineTo(cx, lowcoord);
       
   169             marker.moveTo(cx, closecoord);
       
   170             marker.lineTo(right, closecoord);
       
   171         }
       
   172         upmarker.end();
       
   173         downmarker.end();
       
   174     },
       
   175 
       
   176     /**
       
   177      * Toggles visibility
       
   178      *
       
   179      * @method _toggleVisible
       
   180      * @param {Boolean} visible indicates visibilitye
       
   181      * @private
       
   182      */
       
   183     _toggleVisible: function(visible)
       
   184     {
       
   185         this.get("upmarker").set("visible", visible);
       
   186         this.get("downmarker").set("visible", visible);
       
   187     },
       
   188 
       
   189     /**
       
   190      * Destructor implementation for the CartesianSeries class. Calls destroy on all Graphic instances.
       
   191      *
       
   192      * @method destructor
       
   193      * @protected
       
   194      */
       
   195     destructor: function()
       
   196     {
       
   197         var upmarker = this.get("upmarker"),
       
   198             downmarker = this.get("downmarker");
       
   199         if(upmarker)
       
   200         {
       
   201             upmarker.destroy();
       
   202         }
       
   203         if(downmarker)
       
   204         {
       
   205             downmarker.destroy();
       
   206         }
       
   207     },
       
   208 
       
   209     /**
       
   210      * Gets the default value for the `styles` attribute. Overrides
       
   211      * base implementation.
       
   212      *
       
   213      * @method _getDefaultStyles
       
   214      * @return Object
       
   215      * @private
       
   216      */
       
   217     _getDefaultStyles: function()
       
   218     {
       
   219         var styles = {
       
   220             upmarker: {
       
   221                 stroke: {
       
   222                     color: "#00aa00",
       
   223                     alpha: 1,
       
   224                     weight: 1
       
   225                 }
       
   226             },
       
   227             downmarker: {
       
   228                 stroke: {
       
   229                     color: "#aa0000",
       
   230                     alpha: 1,
       
   231                     weight: 1
       
   232                 }
       
   233             }
       
   234         };
       
   235         return this._mergeStyles(styles, OHLCSeries.superclass._getDefaultStyles());
       
   236     }
       
   237 });
       
   238 Y.OHLCSeries = OHLCSeries;
       
   239 
       
   240 
       
   241 }, '3.10.3', {"requires": ["series-range"]});