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
var series = chart.marker();
66
// the name for display is beautified
67
var 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
var 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(Object.assign(item, {
92
x: item['Vaccine platform description'],
93
y: item['Phase']
94
}));
95
}
96
97
// loop through the dataset
98
// point by point
99
data.forEach(function (vaccine) {
100
addPoint(vaccine);
101
});
102
103
// spread bullets throughout a sector
104
chart.spreadValues('valueEqual');
105
106
// define the legend and specify the parameters
107
var legend = chart.legend();
108
legend.enabled(true);
109
legend.position('right');
110
legend.itemsLayout('vertical');
111
legend.align('center');
112
113
// configure the tooltip
114
chart
115
.tooltip()
116
.titleFormat('{%y}')
117
.format(function () {
118
return (
119
'Type of Vaccine - ' +
120
this.getData('Type of candidate vaccine ') +
121
'\n Doses - ' +
122
this.getData('Number of doses') +
123
'\n Developers - ' +
124
this.getData('Developers ') +
125
'\n Mode of administration - ' +
126
this.getData('Route of administration') +
127
'\n Schedule - ' +
128
this.getData('Schedule')
129
);
130
});
131
132
// set the chart title
133
chart.title('COVID-19 Vaccine Pipeline');
134
135
// set the chart container id
136
chart.container('container');
137
138
// draw the resulting bullseye chart
139
chart.draw();
140
}
141
);
142
});