[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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-base', function (Y, NAME) { 9 10 /** 11 * Provides functionality for creating a chart series. 12 * 13 * @module charts 14 * @submodule series-base 15 */ 16 17 /** 18 * An abstract class for creating series instances. 19 * SeriesBase is used by the following classes: 20 * <ul> 21 * <li>{{#crossLink "CartesianSeries"}}{{/crossLink}}</li> 22 * <li>{{#crossLink "PieSeries"}}{{/crossLink}}</li> 23 * </ul> 24 * 25 * @class SeriesBase 26 * @extends Base 27 * @uses Renderer 28 * @constructor 29 * @param {Object} config (optional) Configuration parameters. 30 * @submodule series-base 31 */ 32 Y.SeriesBase = Y.Base.create("seriesBase", Y.Base, [Y.Renderer], { 33 /** 34 * @method render 35 * @private 36 */ 37 render: function() 38 { 39 this._setCanvas(); 40 this.addListeners(); 41 this.validate(); 42 }, 43 44 /** 45 * Creates a `Graphic` instance. 46 * 47 * @method _setCanvas 48 * @protected 49 */ 50 _setCanvas: function() 51 { 52 var graph = this.get("graph"), 53 graphic = graph.get("graphic"); 54 this.set("graphic", graphic); 55 }, 56 57 /** 58 * Returns a reference to the parent container to which all chart elements are contained. 59 * When the series is bound to a `Chart` instance, the `Chart` instance is the reference. 60 * If nothing is set as the `chart` attribute, the `_getChart` method will return a reference 61 * to the `graphic` attribute. 62 * 63 * @method _getChart 64 * @return {Object} 65 * @private 66 */ 67 _getChart:function() { 68 var chart, 69 graph = this.get("graph"); 70 if(graph) 71 { 72 chart = graph.get("chart"); 73 } 74 if(!chart) 75 { 76 chart = this.get("graphic"); 77 } 78 return chart; 79 }, 80 81 /** 82 * Returns the sum of all values for the series. 83 * 84 * @method getTotalValues 85 * @return Number 86 */ 87 getTotalValues: function() 88 { 89 var valueCoord = this.get("direction") === "vertical" ? "x" : "y", 90 total = this.get(valueCoord + "Axis").getTotalByKey(this.get(valueCoord + "Key")); 91 return total; 92 }, 93 94 /** 95 * Gets the default value for the `styles` attribute. Overrides 96 * base implementation. 97 * 98 * @method _getDefaultStyles 99 * @return Object 100 * @protected 101 */ 102 _getDefaultStyles: function() 103 { 104 return {padding:{ 105 top: 0, 106 left: 0, 107 right: 0, 108 bottom: 0 109 }}; 110 }, 111 112 /** 113 * Shows/hides contents of the series. 114 * 115 * @method _handleVisibleChange 116 * @param {Object} e Event object. 117 * @protected 118 */ 119 _handleVisibleChange: function() 120 { 121 this._toggleVisible(this.get("visible")); 122 }, 123 124 /** 125 * Destructor implementation for the CartesianSeries class. Calls destroy on all Graphic instances. 126 * 127 * @method destructor 128 * @protected 129 */ 130 destructor: function() 131 { 132 var marker, 133 markers = this.get("markers"); 134 if(this.get("rendered")) 135 { 136 if(this._stylesChangeHandle) 137 { 138 this._stylesChangeHandle.detach(); 139 } 140 if(this._widthChangeHandle) 141 { 142 this._widthChangeHandle.detach(); 143 } 144 if(this._heightChangeHandle) 145 { 146 this._heightChangeHandle.detach(); 147 } 148 if(this._visibleChangeHandle) 149 { 150 this._visibleChangeHandle.detach(); 151 } 152 } 153 while(markers && markers.length > 0) 154 { 155 marker = markers.shift(); 156 if(marker && marker instanceof Y.Shape) 157 { 158 marker.destroy(); 159 } 160 } 161 if(this._path) 162 { 163 this._path.destroy(); 164 this._path = null; 165 } 166 if(this._lineGraphic) 167 { 168 this._lineGraphic.destroy(); 169 this._lineGraphic = null; 170 } 171 if(this._groupMarker) 172 { 173 this._groupMarker.destroy(); 174 this._groupMarker = null; 175 } 176 }, 177 178 /** 179 * Collection of default colors used for lines in a series when not specified by user. 180 * 181 * @property _defaultLineColors 182 * @type Array 183 * @protected 184 */ 185 _defaultLineColors:[ 186 "#426ab3", 187 "#d09b2c", 188 "#000000", 189 "#b82837", 190 "#b384b5", 191 "#ff7200", 192 "#779de3", 193 "#cbc8ba", 194 "#7ed7a6", 195 "#007a6c" 196 ], 197 198 /** 199 * Collection of default colors used for marker fills in a series when not specified by user. 200 * 201 * @property _defaultFillColors 202 * @type Array 203 * @protected 204 */ 205 _defaultFillColors:[ 206 "#6084d0", 207 "#eeb647", 208 "#6c6b5f", 209 "#d6484f", 210 "#ce9ed1", 211 "#ff9f3b", 212 "#93b7ff", 213 "#e0ddd0", 214 "#94ecba", 215 "#309687" 216 ], 217 218 /** 219 * Collection of default colors used for marker borders in a series when not specified by user. 220 * 221 * @property _defaultBorderColors 222 * @type Array 223 * @protected 224 */ 225 _defaultBorderColors:[ 226 "#205096", 227 "#b38206", 228 "#000000", 229 "#94001e", 230 "#9d6fa0", 231 "#e55b00", 232 "#5e85c9", 233 "#adab9e", 234 "#6ac291", 235 "#006457" 236 ], 237 238 /** 239 * Collection of default colors used for area fills, histogram fills and pie fills in a series when not specified by user. 240 * 241 * @property _defaultSliceColors 242 * @type Array 243 * @protected 244 */ 245 _defaultSliceColors: [ 246 "#66007f", 247 "#a86f41", 248 "#295454", 249 "#996ab2", 250 "#e8cdb7", 251 "#90bdbd", 252 "#000000", 253 "#c3b8ca", 254 "#968373", 255 "#678585" 256 ], 257 258 /** 259 * Parses a color based on a series order and type. 260 * 261 * @method _getDefaultColor 262 * @param {Number} index Index indicating the series order. 263 * @param {String} type Indicates which type of object needs the color. 264 * @return String 265 * @protected 266 */ 267 _getDefaultColor: function(index, type) 268 { 269 var colors = { 270 line: this._defaultLineColors, 271 fill: this._defaultFillColors, 272 border: this._defaultBorderColors, 273 slice: this._defaultSliceColors 274 }, 275 col = colors[type] || colors.fill, 276 l = col.length; 277 index = index || 0; 278 if(index >= l) 279 { 280 index = index % l; 281 } 282 type = type || "fill"; 283 return colors[type][index]; 284 } 285 }, { 286 ATTRS: { 287 /* 288 * Returns the width of the parent graph 289 * 290 * @attribute width 291 * @type Number 292 */ 293 width: { 294 readOnly: true, 295 296 getter: function() 297 { 298 return this.get("graphic").get("width"); 299 } 300 }, 301 302 /** 303 * Returns the height of the parent graph 304 * 305 * @attribute height 306 * @type Number 307 */ 308 height: { 309 readOnly: true, 310 311 getter: function() 312 { 313 return this.get("graphic").get("height"); 314 } 315 }, 316 317 /** 318 * The graphic in which drawings will be rendered. 319 * 320 * @attribute graphic 321 * @type Graphic 322 */ 323 graphic: { 324 lazyAdd: false, 325 326 setter: function(val) { 327 //woraround for Attribute order of operations bug 328 if(!this.get("rendered")) { 329 this.set("rendered", true); 330 } 331 return val; 332 } 333 }, 334 335 /** 336 * Reference to the `Chart` application. If no `Chart` application is present, 337 * a reference to the `Graphic` instance that the series is drawn into will be returned. 338 * 339 * @attribute chart 340 * @type ChartBase 341 */ 342 chart: { 343 getter: function() 344 { 345 var chart, 346 graph = this.get("graph"); 347 if(graph) 348 { 349 chart = graph.get("chart"); 350 } 351 return chart; 352 } 353 }, 354 355 /** 356 * Reference to the `Graph` in which the series is drawn into. 357 * 358 * @attribute graph 359 * @type Graph 360 */ 361 graph: {}, 362 363 /** 364 * Indicates whether the Series has been through its initial set up. 365 * 366 * @attribute rendered 367 * @type Boolean 368 */ 369 rendered: { 370 value: false 371 }, 372 373 /** 374 * Indicates whether to show the series 375 * 376 * @attribute visible 377 * @type Boolean 378 * @default true 379 */ 380 visible: { 381 value: true 382 }, 383 384 /** 385 * Indicates whether or not markers for a series will be grouped and rendered in a single complex shape instance. 386 * 387 * @attribute groupMarkers 388 * @type Boolean 389 */ 390 groupMarkers: { 391 getter: function() 392 { 393 var graph, 394 groupMarkers = this._groupMarkers; 395 if(!groupMarkers) { 396 graph = this.get("graph"); 397 if(graph) 398 { 399 groupMarkers = graph.get("groupMarkers"); 400 } 401 } 402 return groupMarkers; 403 }, 404 405 setter: function(val) 406 { 407 this._groupMarkers = val; 408 return val; 409 } 410 } 411 } 412 }); 413 414 415 }, '3.17.2', {"requires": ["graphics", "axis-base"]});
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |