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 the font size for labels
47
chart.xAxis().labels().fontSize(10);
48
49
// set a single marker type
50
chart.markerPalette(["circle"]);
51
52
// set the chart color palette
53
chart.palette([
54
"#dce778",
55
"#c8e4fb",
56
"#35baf6",
57
"#ff8b66",
58
"#f55d2c",
59
"#e7cbeb"
60
]);
61
62
// set a series with the given properties
63
function createSeries(seriesId) {
64
// create a series
65
const series = chart.marker();
66
// the name for display is beautified
67
const seriesName =
68
seriesId +
69
(seriesId == "NR" ? "" : seriesId == 1 ? " dose" : " doses");
70
// set the size, name, id and color
71
series.size(2).name(seriesName).id(seriesId);
72
// configure the legend
73
series.legendItem().iconType("circle").iconSize(8);
74
return series;
75
}
76
77
// add a marker series with the given data
78
function addPoint(item) {
79
// the number of doses is a series id
80
const seriesId = item["Number of doses"];
81
// check if there is a series like we need
82
var series = chart.getSeries(seriesId);
83
// if there is no such series we create and configure it
84
if (series == null) {
85
series = createSeries(seriesId);
86
}
87
// add the data into the series
88
series
89
.data()
90
.getDataSets()[0]
91
.append({
92
x: item["Vaccine platform description"],
93
y: item["Phase"],
94
...item
95
});
96
}
97
98
// loop through the dataset
99
// point by point
100
data.forEach((vaccine) => addPoint(vaccine));
101
102
// spread bullets throughout a sector
103
chart.spreadValues("valueEqual");
104
105
// define the legend and specify the parameters
106
let legend = chart.legend();
107
legend.enabled(true);
108
legend.position("right");
109
legend.itemsLayout("vertical");
110
legend.align("center");
111
112
// configure the tooltip
113
chart
114
.tooltip()
115
.titleFormat("{%y}")
116
.format(function () {
117
return (
118
"Type of Vaccine - " +
119
this.getData("Type of candidate vaccine ") +
120
"\n Doses - " +
121
this.getData("Number of doses") +
122
"\n Developers - " +
123
this.getData("Developers ") +
124
"\n Mode of administration - " +
125
this.getData("Route of administration") +
126
"\n Schedule - " +
127
this.getData("Schedule")
128
);
129
});
130
131
// set the chart title
132
chart.title("COVID-19 Vaccine Pipeline");
133
134
// set the chart container id
135
chart.container("container");
136
137
// draw the resulting bullseye chart
138
chart.draw();
139
}
140
);
141
});