Subversion-Projekte lars-tiefland.ci

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
875 lars 1
<!DOCTYPE HTML>
2
<html>
3
	<head>
4
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
		<title>Highcharts Example</title>
6
 
7
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
8
		<style type="text/css">
9
${demo.css}
10
		</style>
11
		<script type="text/javascript">
12
$(function () {
13
 
14
    /**
15
     * Get the current time
16
     */
17
    function getNow() {
18
        var now = new Date();
19
 
20
        return {
21
            hours: now.getHours() + now.getMinutes() / 60,
22
            minutes: now.getMinutes() * 12 / 60 + now.getSeconds() * 12 / 3600,
23
            seconds: now.getSeconds() * 12 / 60
24
        };
25
    }
26
 
27
    /**
28
     * Pad numbers
29
     */
30
    function pad(number, length) {
31
        // Create an array of the remaining length + 1 and join it with 0's
32
        return new Array((length || 2) + 1 - String(number).length).join(0) + number;
33
    }
34
 
35
    var now = getNow();
36
 
37
    // Create the chart
38
    $('#container').highcharts({
39
 
40
        chart: {
41
            type: 'gauge',
42
            plotBackgroundColor: null,
43
            plotBackgroundImage: null,
44
            plotBorderWidth: 0,
45
            plotShadow: false,
46
            height: 200
47
        },
48
 
49
        credits: {
50
            enabled: false
51
        },
52
 
53
        title: {
54
            text: 'The Highcharts clock'
55
        },
56
 
57
        pane: {
58
            background: [{
59
                // default background
60
            }, {
61
                // reflex for supported browsers
62
                backgroundColor: Highcharts.svg ? {
63
                    radialGradient: {
64
                        cx: 0.5,
65
                        cy: -0.4,
66
                        r: 1.9
67
                    },
68
                    stops: [
69
                        [0.5, 'rgba(255, 255, 255, 0.2)'],
70
                        [0.5, 'rgba(200, 200, 200, 0.2)']
71
                    ]
72
                } : null
73
            }]
74
        },
75
 
76
        yAxis: {
77
            labels: {
78
                distance: -20
79
            },
80
            min: 0,
81
            max: 12,
82
            lineWidth: 0,
83
            showFirstLabel: false,
84
 
85
            minorTickInterval: 'auto',
86
            minorTickWidth: 1,
87
            minorTickLength: 5,
88
            minorTickPosition: 'inside',
89
            minorGridLineWidth: 0,
90
            minorTickColor: '#666',
91
 
92
            tickInterval: 1,
93
            tickWidth: 2,
94
            tickPosition: 'inside',
95
            tickLength: 10,
96
            tickColor: '#666',
97
            title: {
98
                text: 'Powered by<br/>Highcharts',
99
                style: {
100
                    color: '#BBB',
101
                    fontWeight: 'normal',
102
                    fontSize: '8px',
103
                    lineHeight: '10px'
104
                },
105
                y: 10
106
            }
107
        },
108
 
109
        tooltip: {
110
            formatter: function () {
111
                return this.series.chart.tooltipText;
112
            }
113
        },
114
 
115
        series: [{
116
            data: [{
117
                id: 'hour',
118
                y: now.hours,
119
                dial: {
120
                    radius: '60%',
121
                    baseWidth: 4,
122
                    baseLength: '95%',
123
                    rearLength: 0
124
                }
125
            }, {
126
                id: 'minute',
127
                y: now.minutes,
128
                dial: {
129
                    baseLength: '95%',
130
                    rearLength: 0
131
                }
132
            }, {
133
                id: 'second',
134
                y: now.seconds,
135
                dial: {
136
                    radius: '100%',
137
                    baseWidth: 1,
138
                    rearLength: '20%'
139
                }
140
            }],
141
            animation: false,
142
            dataLabels: {
143
                enabled: false
144
            }
145
        }]
146
    },
147
 
148
        // Move
149
        function (chart) {
150
            setInterval(function () {
151
 
152
                now = getNow();
153
 
154
                var hour = chart.get('hour'),
155
                    minute = chart.get('minute'),
156
                    second = chart.get('second'),
157
                    // run animation unless we're wrapping around from 59 to 0
158
                    animation = now.seconds === 0 ?
159
                            false :
160
                            {
161
                                easing: 'easeOutElastic'
162
                            };
163
 
164
                // Cache the tooltip text
165
                chart.tooltipText =
166
                    pad(Math.floor(now.hours), 2) + ':' +
167
                    pad(Math.floor(now.minutes * 5), 2) + ':' +
168
                    pad(now.seconds * 5, 2);
169
 
170
                hour.update(now.hours, true, animation);
171
                minute.update(now.minutes, true, animation);
172
                second.update(now.seconds, true, animation);
173
 
174
            }, 1000);
175
 
176
        });
177
});
178
 
179
// Extend jQuery with some easing (copied from jQuery UI)
180
$.extend($.easing, {
181
    easeOutElastic: function (x, t, b, c, d) {
182
        var s=1.70158;var p=0;var a=c;
183
        if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
184
        if (a < Math.abs(c)) { a=c; var s=p/4; }
185
        else var s = p/(2*Math.PI) * Math.asin (c/a);
186
        return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
187
    }
188
});
189
		</script>
190
	</head>
191
	<body>
192
<script src="../../js/highcharts.js"></script>
193
<script src="../../js/highcharts-more.js"></script>
194
 
195
<div id="container" style="width: 300px; height: 300px; margin: 0 auto"></div>
196
 
197
	</body>
198
</html>