HTMLcopy
1
<table class="tg">
2
<thead>
3
<tr>
4
<th id="tg-head" colspan="2">
5
COVID19 Vaccination - How far are we from the halfway mark?
6
</th>
7
</tr>
8
</thead>
9
<tbody>
10
<tr>
11
<td id="td-0-0">World</td>
12
<td id="td-0-1"></td>
13
</tr>
14
<tr>
15
<td id="td-1-0">Europe</td>
16
<td id="td-1-1"></td>
17
</tr>
18
<tr>
19
<td id="td-2-0">North America</td>
20
<td id="td-2-1"></td>
21
</tr>
22
<tr>
23
<td id="td-3-0">South America</td>
24
<td id="td-3-1"></td>
25
</tr>
26
<tr>
27
<td id="td-4-0">Asia</td>
28
<td id="td-4-1"></td>
29
</tr>
30
<tr>
31
<td id="td-5-0">Oceania</td>
32
<td id="td-5-1"></td>
33
</tr>
34
<tr>
35
<td id="td-6-0">Africa</td>
36
<td id="td-6-1"></td>
37
</tr>
38
</tbody>
39
</table>
CSScopy
x
1
html, body, .tg {
2
width: 100%;
3
}
4
5
.tg, thead {
6
height: 10%;
7
color: #7c868e;
8
}
JavaScriptcopy
61
1
anychart.onDocumentReady(function () {
2
// Create and return simple linear gauge
3
function drawGauge(value, settings, name, tableRow) {
4
// Create gauge with settings
5
const gauge = anychart.gauges.linear();
6
gauge.data([value, settings.value]);
7
gauge.layout('horizontal');
8
9
// enable a11y - accessibility settings
10
// you can learn more in documentation article - https://docs.anychart.com/Common_Settings/Accessibility/Settings
11
gauge.a11y(true);
12
// format the description text for a screen reader
13
gauge.a11y().titleFormat(function(e){
14
return `${name} gauge chart. The first value is ${value} and the second one is ${settings.value}`;
15
});
16
17
// Set scale for gauge
18
const scale = anychart.scales.linear();
19
scale.minimum(0).maximum(settings.maximum).ticks({ interval: 2 });
20
21
// Set axis for gauge
22
const axis = gauge.axis(0);
23
axis.width('1%').offset('43%').scale(scale).orientation('bottom');
24
25
// Create and set bar point
26
const barSeries = gauge.bar(0);
27
barSeries
28
.scale(scale)
29
.width('4%');
30
31
// Create and set label with actual data
32
const labelBar = barSeries.labels();
33
labelBar
34
.enabled(true)
35
.offsetY('-15px');
36
37
// Create and set LED point
38
const ledPointer = gauge.led(1);
39
ledPointer
40
.offset('10%')
41
.width('30%')
42
.count(settings.maximum)
43
.scale(scale)
44
.gap(0.55)
45
.dimmer(function () {
46
return '#eee';
47
});
48
ledPointer.colorScale().colors(['#63b39b', '#63b39b']);
49
50
gauge.container(`td-${tableRow}-1`).draw();
51
}
52
53
// Create gauges
54
drawGauge(13.68, { maximum: 50, value: 27.13 }, 'world', 0);
55
drawGauge(36.98, { maximum: 50, value: 47.28 }, 'europe', 1);
56
drawGauge(36.77, { maximum: 50, value: 46.53 }, 'north america', 2);
57
drawGauge(22.8, { maximum: 50, value: 40.54 }, 'south america', 3);
58
drawGauge(10.14, { maximum: 50, value: 27.16 }, 'asia', 4);
59
drawGauge(9.75, { maximum: 50, value: 22.12 }, 'oceania', 5);
60
drawGauge(1.56, { maximum: 50, value: 3.04 }, 'africa', 6);
61
});