forked from Mikhus/canvas-gauges
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample-custom-resize.html
70 lines (66 loc) · 2.03 KB
/
example-custom-resize.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html style="width:100%;height:100%">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Gauge Test</title>
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script>var CANV_GAUGE_FONTS_PATH = '../fonts'</script>
<script src="../gauge.min.js"></script>
<style>body{padding:0;margin:0;background:#222}</style>
</head>
<body style="width:100%;height:100%">
<canvas id="temp-gauge"></canvas>
<div id="console"></div>
<script>
var tempGauge = new Gauge({
renderTo: 'temp-gauge',
width: 380,
height: 380,
glow: true,
units: '°C',
title: 'Temperature',
minValue: -10,
maxValue: 50,
majorTicks: [ -10, 0, 10, 20, 30, 40, 50 ],
minorTicks: 10,
strokeTicks: false,
highlights: [
{ from: -10, to: 0, color: 'rgba(0, 0, 255, .3)' },
{ from: 0, to: 10, color: 'rgba(0, 0, 255, .1)' },
{ from: 30, to: 35, color: 'rgba(255, 255, 0, .3)' },
{ from: 35, to: 50, color: 'rgba(255, 0, 0, .3)' }
],
colors: {
plate: '#f5f5f5',
majorTicks: '#666',
minorTicks: '#888',
title: '#444',
units: '#000',
numbers: '#222',
needle: {
start: 'rgba(240, 128, 128, 2)',
end: 'rgba(255, 160, 122, .9)'
}
},
animation: {
duration: 500,
fn : 'linear'
},
valueFormat: {
int: 2,
dec: 1
}
});
tempGauge.onready = function() {
tempGauge.setValue(0);
};
tempGauge.draw();
$(window).resize(function() {
if ($(window).width() < 1200) {
tempGauge.updateConfig({ width: 300, height: 300 });
} else {
tempGauge.updateConfig({ width: 380, height: 380 });
}
});
</script>
</html>