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-histogram-base', function (Y, NAME) {
11 * Provides core functionality for creating a bar or column series.
14 * @submodule series-histogram
19 * Histogram is the base class for Column and Bar series.
23 * @param {Object} config (optional) Configuration parameters.
24 * @submodule series-histogram
26 function Histogram(){}
28 Histogram.prototype = {
35 drawSeries: function()
37 if(this.get("xcoords").length < 1)
41 var style = Y.clone(this.get("styles").marker),
42 graphic = this.get("graphic"),
45 xcoords = this.get("xcoords"),
46 ycoords = this.get("ycoords"),
50 seriesTypeCollection = this.get("seriesTypeCollection"),
51 seriesLen = seriesTypeCollection.length || 0,
57 order = this.get("order"),
58 graphOrder = this.get("graphOrder"),
78 groupMarkers = this.get("groupMarkers");
79 if(Y_Lang.isArray(style.fill.color))
81 fillColors = style.fill.color.concat();
83 if(Y_Lang.isArray(style.border.color))
85 borderColors = style.border.color.concat();
87 if(this.get("direction") === "vertical")
89 setSizeKey = "height";
90 calculatedSizeKey = "width";
95 calculatedSizeKey = "height";
97 setSize = style[setSizeKey];
98 calculatedSize = style[calculatedSizeKey];
99 this._createMarkerCache();
100 for(; i < seriesLen; ++i)
102 renderer = seriesTypeCollection[i];
103 seriesSize += renderer.get("styles").marker[setSizeKey];
109 totalSize = len * seriesSize;
110 this._maxSize = graphic.get(setSizeKey);
111 if(totalSize > this._maxSize)
113 ratio = graphic.get(setSizeKey)/totalSize;
117 setSize = Math.max(setSize, 1);
118 this._maxSize = setSize;
120 offset -= seriesSize/2;
121 for(i = 0; i < len; ++i)
123 xMarkerPlaneLeft = xcoords[i] - seriesSize/2;
124 xMarkerPlaneRight = xMarkerPlaneLeft + seriesSize;
125 yMarkerPlaneTop = ycoords[i] - seriesSize/2;
126 yMarkerPlaneBottom = yMarkerPlaneTop + seriesSize;
127 xMarkerPlane.push({start: xMarkerPlaneLeft, end: xMarkerPlaneRight});
128 yMarkerPlane.push({start: yMarkerPlaneTop, end: yMarkerPlaneBottom});
129 if(isNaN(xcoords[i]) || isNaN(ycoords[i]))
131 this._markers.push(null);
134 config = this._getMarkerDimensions(xcoords[i], ycoords[i], calculatedSize, offset);
135 if(!isNaN(config.calculatedSize) && config.calculatedSize > 0)
142 dimensions[setSizeKey][i] = setSize;
143 dimensions[calculatedSizeKey][i] = config.calculatedSize;
149 style[setSizeKey] = setSize;
150 style[calculatedSizeKey] = config.calculatedSize;
155 style.fill.color = fillColors[i % fillColors.length];
159 style.border.color = borderColors[i % borderColors.length];
161 marker = this.getMarker(style, graphOrder, i);
165 else if(!groupMarkers)
167 this._markers.push(null);
170 this.set("xMarkerPlane", xMarkerPlane);
171 this.set("yMarkerPlane", yMarkerPlane);
174 this._createGroupMarker({
176 border: style.border,
177 dimensions: dimensions,
185 this._clearMarkerCache();
190 * Collection of default colors used for marker fills in a series when not specified by user.
192 * @property _defaultFillColors
196 _defaultFillColors: ["#66007f", "#a86f41", "#295454", "#996ab2", "#e8cdb7", "#90bdbd","#000000","#c3b8ca", "#968373", "#678585"],
199 * Gets the default style values for the markers.
201 * @method _getPlotDefaults
205 _getPlotDefaults: function()
230 defs.fill.color = this._getDefaultColor(this.get("graphOrder"), "fill");
231 defs.border.color = this._getDefaultColor(this.get("graphOrder"), "border");
236 Y.Histogram = Histogram;
239 }, '3.13.0', {"requires": ["series-cartesian", "series-plot-util"]});