~michael.nelson/ubuntu-webcatalog/1267731-import-sca-apps-error

« back to all changes in this revision

Viewing changes to src/webcatalog/static/yui/3.10.3/build/series-histogram-base/series-histogram-base.js

  • Committer: Tarmac
  • Author(s): Stephen Stewart
  • Date: 2013-06-26 09:19:32 UTC
  • mfrom: (184.1.4 ubuntu-global-nav)
  • Revision ID: tarmac-20130626091932-8urtuli368k8p7ds
[r=beuno,jonas-drange] add ubuntu global nav to apps.ubuntu.com

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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-histogram-base', function (Y, NAME) {
 
9
 
 
10
/**
 
11
 * Provides core functionality for creating a bar or column series.
 
12
 *
 
13
 * @module charts
 
14
 * @submodule series-histogram
 
15
 */
 
16
var Y_Lang = Y.Lang;
 
17
 
 
18
/**
 
19
 * Histogram is the base class for Column and Bar series.
 
20
 *
 
21
 * @class Histogram
 
22
 * @constructor
 
23
 * @param {Object} config (optional) Configuration parameters.
 
24
 * @submodule series-histogram
 
25
 */
 
26
function Histogram(){}
 
27
 
 
28
Histogram.prototype = {
 
29
    /**
 
30
     * Draws the series.
 
31
     *
 
32
     * @method drawSeries
 
33
     * @protected
 
34
     */
 
35
    drawSeries: function()
 
36
    {
 
37
        if(this.get("xcoords").length < 1)
 
38
        {
 
39
            return;
 
40
        }
 
41
        var style = Y.clone(this.get("styles").marker),
 
42
            graphic = this.get("graphic"),
 
43
            setSize,
 
44
            calculatedSize,
 
45
            xcoords = this.get("xcoords"),
 
46
            ycoords = this.get("ycoords"),
 
47
            i = 0,
 
48
            len = xcoords.length,
 
49
            top = ycoords[0],
 
50
            seriesTypeCollection = this.get("seriesTypeCollection"),
 
51
            seriesLen = seriesTypeCollection.length || 0,
 
52
            seriesSize = 0,
 
53
            totalSize = 0,
 
54
            offset = 0,
 
55
            ratio,
 
56
            renderer,
 
57
            order = this.get("order"),
 
58
            graphOrder = this.get("graphOrder"),
 
59
            left,
 
60
            marker,
 
61
            setSizeKey,
 
62
            calculatedSizeKey,
 
63
            config,
 
64
            fillColors = null,
 
65
            borderColors = null,
 
66
            xMarkerPlane = [],
 
67
            yMarkerPlane = [],
 
68
            xMarkerPlaneLeft,
 
69
            xMarkerPlaneRight,
 
70
            yMarkerPlaneTop,
 
71
            yMarkerPlaneBottom,
 
72
            dimensions = {
 
73
                width: [],
 
74
                height: []
 
75
            },
 
76
            xvalues = [],
 
77
            yvalues = [],
 
78
            groupMarkers = this.get("groupMarkers");
 
79
        if(Y_Lang.isArray(style.fill.color))
 
80
        {
 
81
            fillColors = style.fill.color.concat();
 
82
        }
 
83
        if(Y_Lang.isArray(style.border.color))
 
84
        {
 
85
            borderColors = style.border.color.concat();
 
86
        }
 
87
        if(this.get("direction") === "vertical")
 
88
        {
 
89
            setSizeKey = "height";
 
90
            calculatedSizeKey = "width";
 
91
        }
 
92
        else
 
93
        {
 
94
            setSizeKey = "width";
 
95
            calculatedSizeKey = "height";
 
96
        }
 
97
        setSize = style[setSizeKey];
 
98
        calculatedSize = style[calculatedSizeKey];
 
99
        this._createMarkerCache();
 
100
        for(; i < seriesLen; ++i)
 
101
        {
 
102
            renderer = seriesTypeCollection[i];
 
103
            seriesSize += renderer.get("styles").marker[setSizeKey];
 
104
            if(order > i)
 
105
            {
 
106
                offset = seriesSize;
 
107
            }
 
108
        }
 
109
        totalSize = len * seriesSize;
 
110
        this._maxSize = graphic.get(setSizeKey);
 
111
        if(totalSize > this._maxSize)
 
112
        {
 
113
            ratio = graphic.get(setSizeKey)/totalSize;
 
114
            seriesSize *= ratio;
 
115
            offset *= ratio;
 
116
            setSize *= ratio;
 
117
            setSize = Math.max(setSize, 1);
 
118
            this._maxSize = setSize;
 
119
        }
 
120
        offset -= seriesSize/2;
 
121
        for(i = 0; i < len; ++i)
 
122
        {
 
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]))
 
130
            {
 
131
                this._markers.push(null);
 
132
                continue;
 
133
            }
 
134
            config = this._getMarkerDimensions(xcoords[i], ycoords[i], calculatedSize, offset);
 
135
            if(!isNaN(config.calculatedSize) && config.calculatedSize > 0)
 
136
            {
 
137
                top = config.top;
 
138
                left = config.left;
 
139
 
 
140
                if(groupMarkers)
 
141
                {
 
142
                    dimensions[setSizeKey][i] = setSize;
 
143
                    dimensions[calculatedSizeKey][i] = config.calculatedSize;
 
144
                    xvalues.push(left);
 
145
                    yvalues.push(top);
 
146
                }
 
147
                else
 
148
                {
 
149
                    style[setSizeKey] = setSize;
 
150
                    style[calculatedSizeKey] = config.calculatedSize;
 
151
                    style.x = left;
 
152
                    style.y = top;
 
153
                    if(fillColors)
 
154
                    {
 
155
                        style.fill.color = fillColors[i % fillColors.length];
 
156
                    }
 
157
                    if(borderColors)
 
158
                    {
 
159
                        style.border.color = borderColors[i % borderColors.length];
 
160
                    }
 
161
                    marker = this.getMarker(style, graphOrder, i);
 
162
                }
 
163
 
 
164
            }
 
165
            else if(!groupMarkers)
 
166
            {
 
167
                this._markers.push(null);
 
168
            }
 
169
        }
 
170
        this.set("xMarkerPlane", xMarkerPlane);
 
171
        this.set("yMarkerPlane", yMarkerPlane);
 
172
        if(groupMarkers)
 
173
        {
 
174
            this._createGroupMarker({
 
175
                fill: style.fill,
 
176
                border: style.border,
 
177
                dimensions: dimensions,
 
178
                xvalues: xvalues,
 
179
                yvalues: yvalues,
 
180
                shape: style.shape
 
181
            });
 
182
        }
 
183
        else
 
184
        {
 
185
            this._clearMarkerCache();
 
186
        }
 
187
    },
 
188
 
 
189
    /**
 
190
     * Collection of default colors used for marker fills in a series when not specified by user.
 
191
     *
 
192
     * @property _defaultFillColors
 
193
     * @type Array
 
194
     * @protected
 
195
     */
 
196
    _defaultFillColors: ["#66007f", "#a86f41", "#295454", "#996ab2", "#e8cdb7", "#90bdbd","#000000","#c3b8ca", "#968373", "#678585"],
 
197
 
 
198
    /**
 
199
     * Gets the default style values for the markers.
 
200
     *
 
201
     * @method _getPlotDefaults
 
202
     * @return Object
 
203
     * @private
 
204
     */
 
205
    _getPlotDefaults: function()
 
206
    {
 
207
        var defs = {
 
208
            fill:{
 
209
                type: "solid",
 
210
                alpha: 1,
 
211
                colors:null,
 
212
                alphas: null,
 
213
                ratios: null
 
214
            },
 
215
            border:{
 
216
                weight: 0,
 
217
                alpha: 1
 
218
            },
 
219
            width: 12,
 
220
            height: 12,
 
221
            shape: "rect",
 
222
 
 
223
            padding:{
 
224
                top: 0,
 
225
                left: 0,
 
226
                right: 0,
 
227
                bottom: 0
 
228
            }
 
229
        };
 
230
        defs.fill.color = this._getDefaultColor(this.get("graphOrder"), "fill");
 
231
        defs.border.color = this._getDefaultColor(this.get("graphOrder"), "border");
 
232
        return defs;
 
233
    }
 
234
};
 
235
 
 
236
Y.Histogram = Histogram;
 
237
 
 
238
 
 
239
}, '3.10.3', {"requires": ["series-cartesian", "series-plot-util"]});