HTMLcopy
1
<div id="container"></div>
CSScopy
x
1
html,
2
body {
3
width: 100%;
4
height: 100%;
5
margin: 0;
6
padding: 0;
7
}
8
9
#container {
10
width: 100%;
11
height: 100%;
12
margin: 0;
13
padding: 0;
14
}
JavaScriptcopy
123
1
2
var data = [32, 100, {value: 75}, '90,339', '210,576'];
3
var dataSet = anychart.data.set(data);
4
5
//function with gauge series
6
var makeBarWithBar = function (gauge, radius) {
7
var stroke = null;
8
9
//set percent label
10
gauge
11
.label(0)
12
.text('<span style="">' + data[0] + '%</span>')
13
.useHtml(true)
14
.hAlign('center')
15
.vAlign('middle')
16
.anchor('center')
17
.fontSize(25)
18
.offsetX("50%")
19
.offsetY("5%");
20
21
//set additional text label
22
gauge
23
.label(1)
24
.text(`<span>£${data[3]} of £${data[4]}</span>`)
25
.anchor('center')
26
.hAlign('center')
27
.useHtml(true)
28
.fontSize(16)
29
.offsetY('-15%')
30
.offsetX('50%')
31
.width('50%')
32
.height('10%')
33
34
//set commentary text
35
gauge
36
.label(2)
37
.text(`<span>purchases quarter to date</span>`)
38
.anchor('center')
39
.hAlign('center')
40
.useHtml(true)
41
.fontSize(12)
42
.offsetY('-25%')
43
.offsetX('50%')
44
.width('50%')
45
.height('10%')
46
47
//set progress bar
48
gauge
49
.bar(0)
50
.dataIndex(0)
51
.radius(radius)
52
.width("22%")
53
.stroke(null)
54
.fill('orange')
55
.zIndex(5);
56
57
//set process bar
58
gauge
59
.bar(1)
60
.dataIndex(1)
61
.radius(radius)
62
.width('22%')
63
.fill('lightgrey')
64
.stroke(stroke)
65
.zIndex(4);
66
67
//set goal bmarker
68
gauge
69
.marker(0)
70
.type("line")
71
.fill('green')
72
.position('center')
73
.radius(radius)
74
.dataIndex(2)
75
.size(10.5)
76
77
78
};
79
80
81
82
anychart.onDocumentReady(function () {
83
var gauge = anychart.gauges.circular();
84
gauge.data(dataSet);
85
86
//set chart parameters
87
gauge
88
.fill('transparent')
89
.stroke(null)
90
.padding(0)
91
.margin(0)
92
.startAngle(0)
93
.sweepAngle(360);
94
95
//set chart axis
96
var axis = gauge.axis().radius(100).width(1).fill(null);
97
98
//set chart axis apperance
99
axis
100
.scale()
101
.minimum(0)
102
.maximum(100)
103
104
axis.labels().enabled(false);
105
axis.ticks().enabled(false);
106
axis.minorTicks().enabled(false);
107
108
//call a series creatin function
109
makeBarWithBar(gauge, 90);
110
111
//set chart angle
112
gauge.startAngle(-100);
113
gauge.sweepAngle(200);
114
115
gauge.background().enabled(true).fill('transparent');
116
gauge.container('container');
117
118
gauge.title().useHtml(true);
119
gauge.title().fontSize(25);
120
gauge.title("<span>Accesories<span> <br> Q2 Target</span>")
121
122
gauge.draw();
123
});