~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-column/series-column.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-column', function (Y, NAME) {
 
9
 
 
10
/**
 
11
 * Provides functionality for creating a column series.
 
12
 *
 
13
 * @module charts
 
14
 * @submodule series-column
 
15
 */
 
16
/**
 
17
 * The ColumnSeries class renders columns positioned horizontally along a category or time axis. The columns'
 
18
 * lengths are proportional to the values they represent along a vertical axis.
 
19
 * and the relevant data points.
 
20
 *
 
21
 * @class ColumnSeries
 
22
 * @extends MarkerSeries
 
23
 * @uses Histogram
 
24
 * @constructor
 
25
 * @param {Object} config (optional) Configuration parameters.
 
26
 * @submodule series-column
 
27
 */
 
28
Y.ColumnSeries = Y.Base.create("columnSeries", Y.MarkerSeries, [Y.Histogram], {
 
29
    /**
 
30
     * Helper method for calculating the size of markers.
 
31
     *
 
32
     * @method _getMarkerDimensions
 
33
     * @param {Number} xcoord The x-coordinate representing the data point for the marker.
 
34
     * @param {Number} ycoord The y-coordinate representing the data point for the marker.
 
35
     * @param {Number} calculatedSize The calculated size for the marker. For a `BarSeries` is it the width. For a `ColumnSeries` it is the height.
 
36
     * @param {Number} offset Distance of position offset dictated by other marker series in the same graph.
 
37
     * @return Object
 
38
     * @private
 
39
     */
 
40
    _getMarkerDimensions: function(xcoord, ycoord, calculatedSize, offset)
 
41
    {
 
42
        var config = {
 
43
            left: xcoord + offset
 
44
        };
 
45
        if(this._bottomOrigin >= ycoord)
 
46
        {
 
47
            config.top = ycoord;
 
48
            config.calculatedSize = this._bottomOrigin - config.top;
 
49
        }
 
50
        else
 
51
        {
 
52
            config.top = this._bottomOrigin;
 
53
            config.calculatedSize = ycoord - this._bottomOrigin;
 
54
        }
 
55
        return config;
 
56
    },
 
57
 
 
58
    /**
 
59
     * Resizes and positions markers based on a mouse interaction.
 
60
     *
 
61
     * @method updateMarkerState
 
62
     * @param {String} type state of the marker
 
63
     * @param {Number} i index of the marker
 
64
     * @protected
 
65
     */
 
66
    updateMarkerState: function(type, i)
 
67
    {
 
68
        if(this._markers && this._markers[i])
 
69
        {
 
70
            var styles = Y.clone(this.get("styles").marker),
 
71
                markerStyles,
 
72
                state = this._getState(type),
 
73
                xcoords = this.get("xcoords"),
 
74
                ycoords = this.get("ycoords"),
 
75
                marker = this._markers[i],
 
76
                markers,
 
77
                seriesStyles,
 
78
                seriesCollection = this.get("seriesTypeCollection"),
 
79
                seriesLen = seriesCollection.length,
 
80
                seriesSize = 0,
 
81
                offset = 0,
 
82
                renderer,
 
83
                n = 0,
 
84
                xs = [],
 
85
                order = this.get("order"),
 
86
                config;
 
87
            markerStyles = state === "off" || !styles[state] ? Y.clone(styles) : Y.clone(styles[state]);
 
88
            markerStyles.fill.color = this._getItemColor(markerStyles.fill.color, i);
 
89
            markerStyles.border.color = this._getItemColor(markerStyles.border.color, i);
 
90
            config = this._getMarkerDimensions(xcoords[i], ycoords[i], styles.width, offset);
 
91
            markerStyles.height = config.calculatedSize;
 
92
            markerStyles.width = Math.min(this._maxSize, markerStyles.width);
 
93
            marker.set(markerStyles);
 
94
            for(; n < seriesLen; ++n)
 
95
            {
 
96
                xs[n] = xcoords[i] + seriesSize;
 
97
                seriesStyles = seriesCollection[n].get("styles").marker;
 
98
                seriesSize += Math.min(this._maxSize, seriesStyles.width);
 
99
                if(order > n)
 
100
                {
 
101
                    offset = seriesSize;
 
102
                }
 
103
                offset -= seriesSize/2;
 
104
            }
 
105
            for(n = 0; n < seriesLen; ++n)
 
106
            {
 
107
                markers = seriesCollection[n].get("markers");
 
108
                if(markers)
 
109
                {
 
110
                    renderer = markers[i];
 
111
                    if(renderer && renderer !== undefined)
 
112
                    {
 
113
                        renderer.set("x", (xs[n] - seriesSize/2));
 
114
                    }
 
115
                }
 
116
            }
 
117
        }
 
118
    }
 
119
}, {
 
120
    ATTRS: {
 
121
        /**
 
122
         * Read-only attribute indicating the type of series.
 
123
         *
 
124
         * @attribute type
 
125
         * @type String
 
126
         * @readOnly
 
127
         * @default column
 
128
         */
 
129
        type: {
 
130
            value: "column"
 
131
        }
 
132
 
 
133
        /**
 
134
         * Style properties used for drawing markers. This attribute is inherited from `MarkerSeries`. Below are the default values:
 
135
         *  <dl>
 
136
         *      <dt>fill</dt><dd>A hash containing the following values:
 
137
         *          <dl>
 
138
         *              <dt>color</dt><dd>Color of the fill. The default value is determined by the order of the series on the graph. The color
 
139
         *              will be retrieved from the below array:<br/>
 
140
         *              `["#66007f", "#a86f41", "#295454", "#996ab2", "#e8cdb7", "#90bdbd","#000000","#c3b8ca", "#968373", "#678585"]`
 
141
         *              </dd>
 
142
         *              <dt>alpha</dt><dd>Number from 0 to 1 indicating the opacity of the marker fill. The default value is 1.</dd>
 
143
         *          </dl>
 
144
         *      </dd>
 
145
         *      <dt>border</dt><dd>A hash containing the following values:
 
146
         *          <dl>
 
147
         *              <dt>color</dt><dd>Color of the border. The default value is determined by the order of the series on the graph. The color
 
148
         *              will be retrieved from the below array:<br/>
 
149
         *              `["#205096", "#b38206", "#000000", "#94001e", "#9d6fa0", "#e55b00", "#5e85c9", "#adab9e", "#6ac291", "#006457"]`
 
150
         *              <dt>alpha</dt><dd>Number from 0 to 1 indicating the opacity of the marker border. The default value is 1.</dd>
 
151
         *              <dt>weight</dt><dd>Number indicating the width of the border. The default value is 1.</dd>
 
152
         *          </dl>
 
153
         *      </dd>
 
154
         *      <dt>width</dt><dd>indicates the width of the marker. The default value is 12.</dd>
 
155
         *      <dt>over</dt><dd>hash containing styles for markers when highlighted by a `mouseover` event. The default
 
156
         *      values for each style is null. When an over style is not set, the non-over value will be used. For example,
 
157
         *      the default value for `marker.over.fill.color` is equivalent to `marker.fill.color`.</dd>
 
158
         *  </dl>
 
159
         *
 
160
         * @attribute styles
 
161
         * @type Object
 
162
         */
 
163
    }
 
164
});
 
165
 
 
166
 
 
167
}, '3.10.3', {"requires": ["series-marker", "series-histogram-base"]});