2
YUI 3.13.0 (build 508226d)
3
Copyright 2013 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
8
YUI.add('series-base', function (Y, NAME) {
11
* Provides functionality for creating a chart series.
14
* @submodule series-base
18
* An abstract class for creating series instances.
19
* SeriesBase is used by the following classes:
21
* <li>{{#crossLink "CartesianSeries"}}{{/crossLink}}</li>
22
* <li>{{#crossLink "PieSeries"}}{{/crossLink}}</li>
29
* @param {Object} config (optional) Configuration parameters.
30
* @submodule series-base
32
Y.SeriesBase = Y.Base.create("seriesBase", Y.Base, [Y.Renderer], {
45
* Creates a `Graphic` instance.
50
_setCanvas: function()
52
var graph = this.get("graph"),
53
graphic = graph.get("graphic");
54
this.set("graphic", graphic);
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.
67
_getChart:function() {
69
graph = this.get("graph");
72
chart = graph.get("chart");
76
chart = this.get("graphic");
82
* Returns the sum of all values for the series.
84
* @method getTotalValues
87
getTotalValues: function()
89
var valueCoord = this.get("direction") === "vertical" ? "x" : "y",
90
total = this.get(valueCoord + "Axis").getTotalByKey(this.get(valueCoord + "Key"));
95
* Gets the default value for the `styles` attribute. Overrides
96
* base implementation.
98
* @method _getDefaultStyles
102
_getDefaultStyles: function()
113
* Shows/hides contents of the series.
115
* @method _handleVisibleChange
116
* @param {Object} e Event object.
119
_handleVisibleChange: function()
121
this._toggleVisible(this.get("visible"));
125
* Destructor implementation for the CartesianSeries class. Calls destroy on all Graphic instances.
130
destructor: function()
133
markers = this.get("markers");
134
if(this.get("rendered"))
136
this._stylesChangeHandle.detach();
137
this._widthChangeHandle.detach();
138
this._heightChangeHandle.detach();
139
this._visibleChangeHandle.detach();
141
while(markers && markers.length > 0)
143
marker = markers.shift();
144
if(marker && marker instanceof Y.Shape)
151
this._path.destroy();
154
if(this._lineGraphic)
156
this._lineGraphic.destroy();
157
this._lineGraphic = null;
159
if(this._groupMarker)
161
this._groupMarker.destroy();
162
this._groupMarker = null;
167
* Collection of default colors used for lines in a series when not specified by user.
169
* @property _defaultLineColors
187
* Collection of default colors used for marker fills in a series when not specified by user.
189
* @property _defaultFillColors
207
* Collection of default colors used for marker borders in a series when not specified by user.
209
* @property _defaultBorderColors
213
_defaultBorderColors:[
227
* Collection of default colors used for area fills, histogram fills and pie fills in a series when not specified by user.
229
* @property _defaultSliceColors
233
_defaultSliceColors: [
247
* Parses a color based on a series order and type.
249
* @method _getDefaultColor
250
* @param {Number} index Index indicating the series order.
251
* @param {String} type Indicates which type of object needs the color.
255
_getDefaultColor: function(index, type)
258
line: this._defaultLineColors,
259
fill: this._defaultFillColors,
260
border: this._defaultBorderColors,
261
slice: this._defaultSliceColors
263
col = colors[type] || colors.fill,
270
type = type || "fill";
271
return colors[type][index];
276
* Returns the width of the parent graph
286
return this.get("graphic").get("width");
291
* Returns the height of the parent graph
301
return this.get("graphic").get("height");
306
* The graphic in which drawings will be rendered.
314
setter: function(val) {
315
//woraround for Attribute order of operations bug
316
if(!this.get("rendered")) {
317
this.set("rendered", true);
324
* Reference to the `Chart` application. If no `Chart` application is present,
325
* a reference to the `Graphic` instance that the series is drawn into will be returned.
334
graph = this.get("graph");
337
chart = graph.get("chart");
344
* Reference to the `Graph` in which the series is drawn into.
352
* Indicates whether the Series has been through its initial set up.
354
* @attribute rendered
362
* Indicates whether to show the series
373
* Indicates whether or not markers for a series will be grouped and rendered in a single complex shape instance.
375
* @attribute groupMarkers
382
groupMarkers = this._groupMarkers;
384
graph = this.get("graph");
387
groupMarkers = graph.get("groupMarkers");
393
setter: function(val)
395
this._groupMarkers = val;
403
}, '3.13.0', {"requires": ["graphics", "axis-base"]});