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
var colorAxisFont = '#7c868e';
2
var darkAccentColor = '#545f69';
3
4
anychart.onDocumentReady(function () {
5
var stage = anychart.graphics.create('container');
6
var gauge = anychart.gauges.circular();
7
gauge.container(stage);
8
gauge
9
.bounds('0', '0', '100%', '100%')
10
.fill(null)
11
.stroke(null)
12
.padding(0)
13
.margin(0);
14
15
gauge
16
.axis()
17
.scale()
18
.minimum(0)
19
.maximum(220)
20
.ticks({ interval: 20 })
21
.minorTicks({ interval: 10 });
22
23
gauge
24
.axis()
25
.startAngle(-130)
26
.sweepAngle(260)
27
.fill('#474747')
28
.zIndex(20)
29
.labels();
30
31
gauge
32
.axis()
33
.labels()
34
.fontWeight('normal')
35
.position('inside')
36
.padding(5)
37
.fontColor('#474747')
38
.fontSize('16px');
39
40
gauge.data([94]);
41
42
gauge.range(0, {
43
from: 160,
44
to: 180,
45
position: 'inside',
46
fill: '#D96B2B',
47
stroke: '1 #000',
48
startSize: 6,
49
endSize: 6,
50
radius: 113,
51
zIndex: 1
52
});
53
gauge.range(1, {
54
from: 180,
55
to: 220,
56
position: 'inside',
57
fill: '#731728',
58
stroke: '1 #000',
59
startSize: 6,
60
endSize: 6,
61
radius: 113,
62
zIndex: 1
63
});
64
65
gauge
66
.label()
67
.text(
68
'<span style="color:' +
69
darkAccentColor +
70
'; font-size: 13px">km/h </span>'
71
)
72
.useHtml(true);
73
74
gauge
75
.label()
76
.hAlign('center')
77
.anchor('center-bottom')
78
.padding(5, 10)
79
.offsetY(70)
80
.offsetX(0)
81
.zIndex(1)
82
.background({ fill: 'white', corners: 3, cornerType: 'ROUND' });
83
84
gauge
85
.label(1)
86
.text(
87
'<span style="color:' +
88
colorAxisFont +
89
'; font-size: 14px">Current speed: 94 </span><br>' +
90
'<span style="color:' +
91
darkAccentColor +
92
'; font-size: 13px">Average: 67 </span>'
93
)
94
.useHtml(true);
95
96
gauge
97
.label(1)
98
.hAlign('center')
99
.anchor('center-top')
100
.padding(5, 10)
101
.offsetY(-20)
102
.offsetX(0)
103
.zIndex(1)
104
.zIndex(1)
105
.background({
106
fill: 'white',
107
stroke: '#c1c1c1',
108
corners: 3,
109
cornerType: 'ROUND'
110
});
111
112
gauge
113
.needle()
114
.fill(null)
115
.stroke('2 ' + darkAccentColor)
116
.startRadius('5%')
117
.endRadius('80%')
118
.startWidth('0.1%')
119
.endWidth('0.1%')
120
.middleWidth('0.1%');
121
122
gauge
123
.cap()
124
.radius('3%')
125
.enabled(true)
126
.fill(darkAccentColor)
127
.stroke(null);
128
129
var internalGauge = anychart.gauges.circular();
130
internalGauge.container(stage);
131
132
internalGauge.background('none');
133
134
internalGauge
135
.data([2100])
136
.padding(0)
137
.fill(null)
138
.margin('40%', 0, 0, 0)
139
.bounds('25%', '50%', '50%', '50%')
140
.stroke('none');
141
142
internalGauge
143
.axis()
144
.scale()
145
.minimum(0)
146
.maximum(9000)
147
.ticks()
148
.interval(1000);
149
150
internalGauge
151
.axis()
152
.startAngle(-90)
153
.sweepAngle(180)
154
.fill('#474747')
155
.zIndex(20)
156
.labels();
157
158
internalGauge
159
.axis()
160
.labels()
161
.fontWeight('normal')
162
.position('inside')
163
.fontFamily('Verdana')
164
.fontColor('#474747')
165
.fontSize('10px');
166
167
internalGauge
168
.axis()
169
.ticks({ type: 'trapezium', fill: '#474747', length: 15 });
170
171
internalGauge
172
.needle()
173
.fill(null)
174
.stroke('2 ' + darkAccentColor)
175
.startRadius('5%')
176
.endRadius('70%')
177
.startWidth('0.1%')
178
.endWidth('0.1%')
179
.middleWidth('0.1%');
180
181
internalGauge
182
.cap()
183
.radius('3%')
184
.enabled(true)
185
.fill(darkAccentColor)
186
.stroke(null);
187
188
internalGauge.range(0, {
189
from: 7000,
190
to: 7500,
191
position: 'inside',
192
fill: '#D96B2B',
193
stroke: '1 #000',
194
startSize: 8,
195
endSize: 8,
196
radius: 115,
197
zIndex: 1
198
});
199
internalGauge.range(1, {
200
from: 7500,
201
to: 9000,
202
position: 'inside',
203
fill: '#731728',
204
stroke: '1 #000',
205
startSize: 8,
206
endSize: 8,
207
radius: 115,
208
zIndex: 1
209
});
210
internalGauge
211
.label(1)
212
.text(
213
'<span style="color:' +
214
colorAxisFont +
215
'; font-size: 14px">Current engine rpm: 2100 </span><br>' +
216
'<span style="color:' +
217
darkAccentColor +
218
'; font-size: 13px">Average rpm: 2236 </span>'
219
)
220
.useHtml(true);
221
internalGauge
222
.label(1)
223
.hAlign('center')
224
.anchor('center-top')
225
.padding(5, 10)
226
.offsetY(-20)
227
.offsetX(0)
228
.zIndex(1)
229
.zIndex(1)
230
.background({
231
fill: 'white',
232
stroke: '#c1c1c1',
233
corners: 3,
234
cornerType: 'ROUND'
235
});
236
237
gauge.draw();
238
internalGauge.draw();
239
});