多用途-半圓形-指針儀表盤1
# FastWeb 多用途-半圓形-指針儀表盤1
圓形指針的儀表盤使用的是Canvas Gauges
,這是一套豐富的JS儀表盤元件庫。
使用的半圓形指針儀表盤的樣式如下:
# 1. 下載示例
點選https://github.com/Mikhus/canvas-gauges/archive/refs/heads/master.zip (opens new window)以下載庫,建議將其中包含的內容解壓縮放置於FastWeb目錄的library/js
資料夾中。
# 2. 確認參數
半圓形指針儀表盤的樣式內容如下:
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Gauge Test</title>
<link rel="stylesheet" href="library/js/canvas-gauges-master/fonts/fonts.css">
<script src="library/js/canvas-gauges-master/gauge.min.js"></script>
<style>body {
padding: 0;
margin: 0;
background: #fff
}</style>
</head>
<body>
<canvas id="canvas-id"></canvas>
<script>
var gauge = new RadialGauge({
renderTo: 'canvas-id',
width: 300,
height: 300,
units: "",
title: "",
startAngle: 90,
ticksAngle: 180,
colorPlate: "#ffffff",
colorUnits: "#3CA7DB",
colorNumbers: "#534638",
colorNeedle: "#8E7860",
colorNeedleEnd: "#8E7860",
colorNeedleCircleOuter: "#8E7860",
colorNeedleCircleOuterEnd: "#8E7860",
colorNeedleShadowUp: "#8E7860",
colorNeedleShadowDown: "#8E7860",
colorMajorTicks: ["#EBEBEB", "#EBEBEB", "#EBEBEB", "#EBEBEB", "#EBEBEB", "#EBEBEB"],
colorMinorTicks: "#EBEBEB",
minValue: 0,
maxValue: 100,
majorTicks: ["","20","40","60","80",""],
minorTicks: "2",
strokeTicks: true,
highlights: [
{
"from": -0.25,
"to": 39.99,
"color": "#FF9488"
},
{
"from": 39.99,
"to": 59.99,
"color": "#8FB9BD"
},
{
"from": 59.99,
"to": 100.25,
"color": "#B1B9CB"
}
],
highlightsWidth: 25,
numbersMargin: 12,
animation: true,
animationRule: "linear",
animatedValue: true,
borders: false,
valueBox: false,
needleType: "arrow",
needleEnd: 65,
needleWidth: 4,
needleCircleSize: 10,
needleCircleInner: false,
needleCircleOuter: true,
needleShadow: false,
borderShadowWidth: 0
}).draw();
gauge.value = 48;
gauge.update();
</script>
</body>
</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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
從上述的語言中,可以找到一個名為gauge.value
的參數,其中得到的值就是半圓形儀表盤指針指向的數值。此處可為其設定參數值為param_value
。
# 3. 修改模板
# 3.1. 本地化處理
上述模板已經將所需的檔案本地化處理,不需要額外進行本地化的相關設定。
# 3.2. 標記參數
將上述的gauge.value
處后的值使用param_value
來代替,替換后的內容如下:
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Gauge Test</title>
<link rel="stylesheet" href="library/js/canvas-gauges-master/fonts/fonts.css">
<script src="library/js/canvas-gauges-master/gauge.min.js"></script>
<style>body {
padding: 0;
margin: 0;
background: #fff
}</style>
</head>
<body>
<canvas id="canvas-id"></canvas>
<script>
var gauge = new RadialGauge({
renderTo: 'canvas-id',
width: 300,
height: 300,
units: "",
title: "",
startAngle: 90,
ticksAngle: 180,
colorPlate: "#ffffff",
colorUnits: "#3CA7DB",
colorNumbers: "#534638",
colorNeedle: "#8E7860",
colorNeedleEnd: "#8E7860",
colorNeedleCircleOuter: "#8E7860",
colorNeedleCircleOuterEnd: "#8E7860",
colorNeedleShadowUp: "#8E7860",
colorNeedleShadowDown: "#8E7860",
colorMajorTicks: ["#EBEBEB", "#EBEBEB", "#EBEBEB", "#EBEBEB", "#EBEBEB", "#EBEBEB"],
colorMinorTicks: "#EBEBEB",
minValue: 0,
maxValue: 100,
majorTicks: ["","20","40","60","80",""],
minorTicks: "2",
strokeTicks: true,
highlights: [
{
"from": -0.25,
"to": 39.99,
"color": "#FF9488"
},
{
"from": 39.99,
"to": 59.99,
"color": "#8FB9BD"
},
{
"from": 59.99,
"to": 100.25,
"color": "#B1B9CB"
}
],
highlightsWidth: 25,
numbersMargin: 12,
animation: true,
animationRule: "linear",
animatedValue: true,
borders: false,
valueBox: false,
needleType: "arrow",
needleEnd: 65,
needleWidth: 4,
needleCircleSize: 10,
needleCircleInner: false,
needleCircleOuter: true,
needleShadow: false,
borderShadowWidth: 0
}).draw();
gauge.value = param_value;
gauge.update();
</script>
</body>
</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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
上述模板內容已設定完成,可在JQuery元件的模板中匯入上述內容。
# 3.3. 設定參數
在參數界面中,設定上述參數,分別為其設定預設值:
# 3.4. 與資料庫欄位聯動
可以設定數據來源於資料庫欄位,可留空表示設定不使用資料庫欄位。