Public
Edited
Mar 20, 2023
Insert cell
Insert cell
Plot.plot({
x:{round: true,
label: "Percentage of articles per Organization",
labelAnchor: "center",
tickFormat: "%",
domain:[0,0.5]},
grid:true,
marginLeft: 150,
margin:50,
y:{label:"Organizations"},
marks: [
Plot.barX(percentages, {y:percentages.keys(),x:percentages.values(),fill:Array.from(percentages.keys()),title:titles,sort: {y: "x", reverse: true}}),
Plot.ruleX([0])
],
color: {legend: true}
})
Insert cell
listOfArticles = FileAttachment("list of articles.xlsx").xlsx()
Insert cell
data = listOfArticles.sheet(0,{ headers: true })
Insert cell
organizations = data.map(column => column.Organization);
Insert cell
lst = {
let lst = []
for (var x=0; x<150; x++){
let i=0;
let o = organizations[x].split(",")[i];
const size = organizations[x].split(",").length;
while (i < size) {
lst.push(o.toUpperCase().trim());
i++;
if (i === size) {
break;
}
o = organizations[x].split(",")[i];
}
}
lst.sort()
return lst
}
Insert cell
counts = lst.reduce((acc, e) => acc.set(e, (acc.get(e) || 0) + 1), new Map());
Insert cell
percentages = {
let percentages = new Map();
for (const [key, value] of counts) {
percentages.set(key, (value/lst.length));
}
return percentages
}
Insert cell
titles = Array.from(percentages.values())
Insert cell
{
for(var i=0;i<16;i++){
titles[i]=titles[i]*100;
}
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more