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
anychart.data.loadJsonFile(
3
"https://gist.githubusercontent.com/shacheeswadia/3cc96d8ed792bfa0c04fbd3825816fde/raw/606c2646df568f30bd39dc01fcd4efe6e92b3bac/vaccineData.json",
4
function (data) {
5
// create a polar chart instance
6
var chart = anychart.polar();
7
// set the inner radius to create a hole in the center
8
chart.innerRadius(80);
9
10
// y scale shows phases
11
// set it as ordinal
12
chart.yScale("ordinal");
13
// define the order of values on the scale
14
chart
15
.yScale()
16
.values([
17
"Phase 4",
18
"Phase 3",
19
"Phase 2/3",
20
"Phase 1/2",
21
"Phase 2",
22
"Phase 1",
23
"NA"
24
]);
25
26
// x scale shows vaccine types
27
// set it as ordinal
28
chart.xScale("ordinal");
29
// define the order of values on the scale
30
chart
31
.xScale()
32
.values([
33
"Bacterial antigen-spore expression vector",
34
"DNA based vaccine",
35
"Inactivated virus",
36
"Live attenuated virus",
37
"Protein subunit",
38
"RNA based vaccine",
39
"Viral vector (Non-replicating)",
40
"Viral vector (Non-replicating) + APC",
41
"Viral vector (Replicating)",
42
"Viral vector (Replicating) + APC",
43
"Virus like particle"
44
]);
45
46
// set a series with the given properties
47
function createSeries(seriesId) {
48
// create a series
49
const series = chart.marker();
50
// the name for display is beautified
51
const seriesName =
52
seriesId +
53
(seriesId == "NR" ? "" : seriesId == 1 ? " dose" : " doses");
54
// set the size, name, id
55
series.size(2).name(seriesName).id(seriesId);
56
return series;
57
}
58
59
// add a marker series with the given data
60
function addPoint(item) {
61
// number of doses is a series id
62
const seriesId = item["Number of doses"];
63
// check if there is a series like we need
64
var series = chart.getSeries(seriesId);
65
// if there is no such series we create and configure it
66
if (series == null) {
67
series = createSeries(seriesId);
68
}
69
// add the data into the series
70
series
71
.data()
72
.getDataSets()[0]
73
.append({
74
x: item["Vaccine platform description"],
75
y: item["Phase"],
76
...item
77
});
78
}
79
80
// loop through the dataset
81
// point by point
82
data.forEach((vaccine) => addPoint(vaccine));
83
84
// spread bullets throughout a sector
85
chart.spreadValues("valueEqual");
86
87
// set the chart title
88
chart.title("COVID-19 Vaccine Pipeline");
89
90
// set the chart container id
91
chart.container("container");
92
93
// draw the resulting bullseye chart
94
chart.draw();
95
}
96
);
97
});