Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
YUI.add('axis-time', function (Y, NAME) {
2
 
3
/**
4
 * Provides functionality for drawing a time axis for use with a chart.
5
 *
6
 * @module charts
7
 * @submodule axis-time
8
 */
9
/**
10
 * TimeAxis draws a time-based axis for a chart.
11
 *
12
 * @class TimeAxis
13
 * @constructor
14
 * @extends Axis
15
 * @uses TimeImpl
16
 * @param {Object} config (optional) Configuration parameters.
17
 * @submodule axis-time
18
 */
19
Y.TimeAxis = Y.Base.create("timeAxis", Y.Axis, [Y.TimeImpl], {
20
    /**
21
     * Calculates and returns a value based on the number of labels and the index of
22
     * the current label.
23
     *
24
     * @method _getLabelByIndex
25
     * @param {Number} i Index of the label.
26
     * @param {Number} l Total number of labels.
27
     * @return String
28
     * @private
29
     */
30
    _getLabelByIndex: function(i, l)
31
    {
32
        var min = this.get("minimum"),
33
            max = this.get("maximum"),
34
            increm,
35
            label;
36
            l -= 1;
37
        increm = ((max - min)/l) * i;
38
        label = min + increm;
39
        return label;
40
    },
41
 
42
    /**
43
     * Returns an object literal containing and array of label values and an array of points.
44
     *
45
     * @method _getLabelData
46
     * @param {Object} startPoint An object containing x and y values.
47
     * @param {Number} edgeOffset Distance to offset coordinates.
48
     * @param {Number} layoutLength Distance that the axis spans.
49
     * @param {Number} count Number of labels.
50
     * @param {String} direction Indicates whether the axis is horizontal or vertical.
51
     * @param {Array} Array containing values for axis labels.
52
     * @return Array
53
     * @private
54
     */
55
    _getLabelData: function(constantVal, staticCoord, dynamicCoord, min, max, edgeOffset, layoutLength, count, dataValues)
56
    {
57
        var dataValue,
58
            i,
59
            points = [],
60
            values = [],
61
            point,
62
            offset = edgeOffset;
63
        dataValues = dataValues || this._getDataValuesByCount(count, min, max);
64
        for(i = 0; i < count; i = i + 1)
65
        {
66
            dataValue = this._getNumber(dataValues[i]);
67
            if(dataValue <= max && dataValue >= min)
68
            {
69
                point = {};
70
                point[staticCoord] = constantVal;
71
                point[dynamicCoord] = this._getCoordFromValue(
72
                    min,
73
                    max,
74
                    layoutLength,
75
                    dataValue,
76
                    offset
77
                );
78
                points.push(point);
79
                values.push(dataValue);
80
            }
81
        }
82
        return {
83
            points: points,
84
            values: values
85
        };
86
    }
87
});
88
 
89
 
90
 
91
}, '3.18.1', {"requires": ["axis", "axis-time-base"]});