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(100)
8
.startAngle(270)
9
.sweepAngle(180);
10
11
gauge
12
.axis()
13
.labels()
14
.padding(5)
15
.fontSize(14)
16
.position('outside')
17
.format('${%Value}k');
18
19
gauge.data([73.2]);
20
gauge
21
.axis()
22
.scale()
23
.minimum(0)
24
.maximum(100)
25
.ticks({ interval: 10 })
26
.minorTicks({ interval: 5 });
27
28
gauge
29
.axis()
30
.fill('#545f69')
31
.width(1)
32
.ticks({ type: 'line', fill: 'white', length: 2 });
33
34
gauge.title(
35
'Assessment of Current Sales<br/>Using Gauge with Color Ranges and Labels<br/>' +
36
'<span style="color:#009900; font-size: 14px;">(Current sales $<strong>73.2</strong>k)</span>'
37
);
38
gauge
39
.title()
40
.useHtml(true)
41
.padding(0)
42
.fontColor('#212121')
43
.hAlign('center')
44
.margin([0, 0, 10, 0]);
45
46
gauge
47
.needle()
48
.stroke('2 #545f69')
49
.startRadius('5%')
50
.endRadius('90%')
51
.startWidth('0.1%')
52
.endWidth('0.1%')
53
.middleWidth('0.1%');
54
55
gauge.cap().radius('3%').enabled(true).fill('#545f69');
56
57
gauge.range(0, {
58
from: 0,
59
to: 30,
60
position: 'inside',
61
fill: '#dd2c00 0.4',
62
startSize: 50,
63
endSize: 50,
64
radius: 98
65
});
66
67
gauge.range(1, {
68
from: 30,
69
to: 70,
70
position: 'inside',
71
fill: '#ffa000 0.4',
72
startSize: 50,
73
endSize: 50,
74
radius: 98
75
});
76
77
gauge.range(2, {
78
from: 70,
79
to: 100,
80
position: 'inside',
81
fill: '#009900 0.4',
82
startSize: 50,
83
endSize: 50,
84
radius: 98
85
});
86
87
gauge
88
.label(1)
89
.text('Poor')
90
.fontColor('#212121')
91
.fontSize(14)
92
.offsetY('68%')
93
.offsetX(25)
94
.anchor('center');
95
96
gauge
97
.label(2)
98
.text('Average')
99
.fontColor('#212121')
100
.fontSize(14)
101
.offsetY('68%')
102
.offsetX(90)
103
.anchor('center');
104
105
gauge
106
.label(3)
107
.text('Good')
108
.fontColor('#212121')
109
.fontSize(14)
110
.offsetY('68%')
111
.offsetX(155)
112
.anchor('center');
113
114
gauge.container('container');
115
gauge.draw();
116
});