HTMLcopy
1
<div id="container"></div>
CSScopy
8
1
html,
2
body,
3
#container {
4
width: 100%;
5
height: 100%;
6
margin: 0;
7
padding: 0;
8
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
var gauge = anychart.gauges.circular();
3
gauge
4
.fill('#fff')
5
.stroke(null)
6
.padding(0)
7
.margin(30)
8
.startAngle(0)
9
.sweepAngle(360);
10
11
gauge
12
.axis()
13
.labels()
14
.padding(3)
15
.position('outside')
16
.format('{%Value}\u00B0');
17
18
gauge.data([120, 12]);
19
20
gauge
21
.axis()
22
.scale()
23
.minimum(0)
24
.maximum(360)
25
.ticks({ interval: 30 })
26
.minorTicks({ interval: 10 });
27
28
gauge
29
.axis()
30
.fill('#7c868e')
31
.startAngle(0)
32
.sweepAngle(-360)
33
.width(1)
34
.ticks({
35
type: 'line',
36
fill: '#7c868e',
37
length: 4,
38
position: 'outside'
39
});
40
41
gauge
42
.axis(1)
43
.fill('#7c868e')
44
.startAngle(270)
45
.radius(40)
46
.sweepAngle(180)
47
.width(1)
48
.ticks({
49
type: 'line',
50
fill: '#7c868e',
51
length: 4,
52
position: 'outside'
53
});
54
55
gauge
56
.axis(1)
57
.labels()
58
.padding(3)
59
.position('outside')
60
.format('{%Value} m/s');
61
62
gauge
63
.axis(1)
64
.scale()
65
.minimum(0)
66
.maximum(25)
67
.ticks({ interval: 5 })
68
.minorTicks({ interval: 1 });
69
70
gauge.title().padding(0).margin([0, 0, 10, 0]);
71
72
gauge
73
.marker()
74
.fill('#64b5f6')
75
.stroke(null)
76
.size('15%')
77
.zIndex(120)
78
.radius('97%');
79
80
gauge
81
.needle()
82
.fill('#1976d2')
83
.stroke(null)
84
.axisIndex(1)
85
.startRadius('6%')
86
.endRadius('38%')
87
.startWidth('2%')
88
.middleWidth(null)
89
.endWidth('0');
90
91
gauge.cap().radius('4%').fill('#1976d2').enabled(true).stroke(null);
92
93
var bigTooltipTitleSettings = {
94
fontFamily: '\'Verdana\', Helvetica, Arial, sans-serif',
95
fontWeight: 'normal',
96
fontSize: '12px',
97
hAlign: 'left',
98
fontColor: '#212121'
99
};
100
101
gauge
102
.label()
103
.text(
104
'<span style="color: #64B5F6; font-size: 13px">Wind Direction: </span>' +
105
'<span style="color: #5AA3DD; font-size: 15px">' +
106
120 +
107
'\u00B0 (+/- 0.5\u00B0)</span><br>' +
108
'<span style="color: #1976d2; font-size: 13px">Wind Speed:</span> ' +
109
'<span style="color: #166ABD; font-size: 15px">' +
110
12 +
111
'm/s</span>'
112
)
113
.useHtml(true)
114
.textSettings(bigTooltipTitleSettings);
115
gauge
116
.label()
117
.hAlign('center')
118
.anchor('center-top')
119
.offsetY(-20)
120
.padding(15, 20)
121
.background({
122
fill: '#fff',
123
stroke: {
124
thickness: 1,
125
color: '#E0F0FD'
126
}
127
});
128
129
// set container id for the chart
130
gauge.container('container');
131
132
// initiate chart drawing
133
gauge.draw();
134
});