Public
Edited
Sep 24, 2023
1 fork
Insert cell
Insert cell
Insert cell
data = FileAttachment("enrollmentzipcode.csv")
Insert cell
enrollmentzipcode.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
modified_stats = {
return enrollmentzipcode.map(obj => {
obj["campus"] = obj['IRO_INSTITUTION_DESCL']
obj['enrollment'] = obj["ENROLLMENT"]
obj['semester'] = obj['SEMESTER']
obj['hawaiian'] = obj['HAWAIIAN_LEGACY']
return obj
})
}
Insert cell
Plotly = require("https://cdn.plot.ly/plotly-latest.min.js")
Insert cell
Insert cell
uni_west_total_ = {
const uni_west = modified_stats.filter(obj =>
obj.campus == "University of Hawai`i - West O`ahu");
const uni_west_total = uni_west.reduce((total, add) => {
const semester = add.semester
const value = parseInt(add.enrollment)

if(total[semester] != undefined) {
total[semester]+= value;
} else {
total[semester] = value
}
return total
},{});

return uni_west_total
}
Insert cell
uni_manoa_total_ = {
const uni_manoa = modified_stats.filter(obj =>
obj.campus == "University of Hawai`i at Manoa");
const uni_manoa_total = uni_manoa.reduce((total, add) => {
const semester = add.semester
const value = parseInt(add.enrollment)

if(total[semester] != undefined) {
total[semester]+= value;
} else {
total[semester] = value
}
return total
},{});
return uni_manoa_total
}
Insert cell
uni_hilo_total_ = {
const uni_hilo = modified_stats.filter(obj =>
obj.campus == "University of Hawai`i at Hilo");
const uni_hilo_total = uni_hilo.reduce((total, add) => {
const semester = add.semester
const value = parseInt(add.enrollment)

if(total[semester] != undefined) {
total[semester]+= value;
} else {
total[semester] = value
}
return total
},{});
return uni_hilo_total
}
Insert cell
uni_maui_total_ = {
const uni_maui = modified_stats.filter(obj =>
obj.campus == "University of Hawai`i Maui College");
const uni_maui_total = uni_maui.reduce((total, add) => {
const semester = add.semester
const value = parseInt(add.enrollment)

if(total[semester] != undefined) {
total[semester]+= value;
} else {
total[semester] = value
}
return total
},{});
return uni_maui_total
}
Insert cell
hon_comm_total_ = {
const hon_comm = modified_stats.filter(obj =>
obj.campus == "Honolulu Community College");
const hon_comm_total = hon_comm.reduce((total, add) => {
const semester = add.semester
const value = parseInt(add.enrollment)

if(total[semester] != undefined) {
total[semester]+= value;
} else {
total[semester] = value
}
return total
},{});

return hon_comm_total
}
Insert cell
kapiolani_total_ = {
const kapiolani = modified_stats.filter(obj =>
obj.campus == "Kapi`olani Community College");
const kapiolani_total = kapiolani.reduce((total, add) => {
const semester = add.semester
const value = parseInt(add.enrollment)

if(total[semester] != undefined) {
total[semester]+= value;
} else {
total[semester] = value
}
return total
},{});
return kapiolani_total
}
Insert cell
windward_total_ = {
const windward = modified_stats.filter(obj =>
obj.campus == "Windward Community College");
const windward_total = windward.reduce((total, add) => {
const semester = add.semester
const value = parseInt(add.enrollment)

if(total[semester] != undefined) {
total[semester]+= value;
} else {
total[semester] = value
}
return total
},{});
return windward_total
}
Insert cell
leeward_total_ = {
const leeward = modified_stats.filter(obj =>
obj.campus == "Leeward Community College");
const leeward_total = leeward.reduce((total, add) => {
const semester = add.semester
const value = parseInt(add.enrollment)

if(total[semester] != undefined) {
total[semester]+= value;
} else {
total[semester] = value
}
return total
},{});
return leeward_total
}
Insert cell
kauai_total_ = {
const kauai = modified_stats.filter(obj =>
obj.campus == "Kaua`i Community College");
const kauai_total = kauai.reduce((total, add) => {
const semester = add.semester
const value = parseInt(add.enrollment)

if(total[semester] != undefined) {
total[semester]+= value;
} else {
total[semester] = value
}
return total
},{});
return kauai_total
}
Insert cell
hawaii_comm_total_ = {
const hawaii_comm = modified_stats.filter(obj =>
obj.campus == "Hawai`i Community College");
const hawaii_comm_total = hawaii_comm.reduce((total, add) => {
const semester = add.semester
const value = parseInt(add.enrollment)

if(total[semester] != undefined) {
total[semester]+= value;
} else {
total[semester] = value
}
return total
},{});
return hawaii_comm_total
}
Insert cell
Insert cell
{
let uni_manoa_data = {
x: Object.keys(uni_manoa_total_),
y: Object.values(uni_manoa_total_),
name: "University of Hawaii at Manoa",
type: 'bar'
};
let uni_hilo_data = {
x: Object.keys(uni_hilo_total_),
y: Object.values(uni_hilo_total_),
name: "University of Hawaii at Hilo",
type: 'bar'
};

let uni_west_data = {
x: Object.keys(uni_west_total_),
y: Object.values(uni_west_total_),
name: "University of Hawaii - West Oahu",
type: 'bar'
};

let uni_maui_data = {
x: Object.keys(uni_maui_total_),
y: Object.values(uni_maui_total_),
name: "University of Hawaii Maui College",
type: 'bar'
};

let hon_comm_data = {
x: Object.keys(hon_comm_total_),
y: Object.values(hon_comm_total_),
name: "Honolulu Community College",
type: 'bar'
};

let kapiolani_data = {
x: Object.keys(kapiolani_total_),
y: Object.values(kapiolani_total_),
name: "Kapiolani Community College",
type: 'bar'
};

let windward_data = {
x: Object.keys(windward_total_),
y: Object.values(windward_total_),
name: "Windward Community College",
type: 'bar'
};

let leeward_data = {
x: Object.keys(leeward_total_),
y: Object.values(leeward_total_),
name: "Leeward Community College",
type: 'bar'
};

let kauai_data = {
x: Object.keys(kauai_total_),
y: Object.values(kauai_total_),
name: "Kauai Community College",
type: 'bar'
};
const hawaii_data = {
x: Object.keys(hawaii_comm_total_),
y: Object.values(hawaii_comm_total_),
name: "Hawaii Community College",
type: 'bar'
};

let layout = { // there are many layout options, in this example we just set the dimensions
height: 400,
width: 900,
barmode: 'group',
};

var data = [uni_manoa_data,hon_comm_data,kapiolani_data, windward_data,leeward_data, uni_hilo_data, uni_west_data, kauai_data,hawaii_data, uni_maui_data];

const div = DOM.element('div');

Plotly.newPlot(div,data,layout)
return div;
}
Insert cell
Insert cell
Insert cell
{
const div = DOM.element('div');
let uni_manoa_data = {
x: Object.keys(uni_manoa_total_),
y: Object.values(uni_manoa_total_),
name: "University of Hawaii at Manoa",
mode: "lines+markers"
};
let uni_hilo_data = {
x: Object.keys(uni_hilo_total_),
y: Object.values(uni_hilo_total_),
name: "University of Hawaii at Hilo",
mode: "lines+markers"
};

let uni_west_data = {
x: Object.keys(uni_west_total_),
y: Object.values(uni_west_total_),
name: "University of Hawaii - West Oahu",
mode: "lines+markers"
};

let uni_maui_data = {
x: Object.keys(uni_maui_total_),
y: Object.values(uni_maui_total_),
name: "University of Hawaii Maui College",
mode: "lines+markers"
};

let hon_comm_data = {
x: Object.keys(hon_comm_total_),
y: Object.values(hon_comm_total_),
name: "Honolulu Community College",
mode: "lines+markers"
};

let kapiolani_data = {
x: Object.keys(kapiolani_total_),
y: Object.values(kapiolani_total_),
name: "Kapiolani Community College",
mode: "lines+markers"
};

let windward_data = {
x: Object.keys(windward_total_),
y: Object.values(windward_total_),
name: "Windward Community College",
mode: "lines+markers"
};

let leeward_data = {
x: Object.keys(leeward_total_),
y: Object.values(leeward_total_),
name: "Leeward Community College",
mode: "lines+markers"
};

let kauai_data = {
x: Object.keys(kauai_total_),
y: Object.values(kauai_total_),
name: "Kauai Community College",
mode: "lines+markers"
};
let hawaii_data = {
x: Object.keys(hawaii_comm_total_),
y: Object.values(hawaii_comm_total_),
name: "Hawaii Community College",
mode: "lines+markers"
};

var data = [uni_manoa_data,hon_comm_data,kapiolani_data, windward_data,leeward_data, uni_hilo_data, uni_west_data, kauai_data,hawaii_data, uni_maui_data];

let layout = { // there are many layout options, in this example we just set the dimensions
title: {
text:'Plot Title',
font: {
family: 'Courier New, monospace',
size: 24
},
xref: 'paper',
x: 0.05,
},
xaxis: {
title: {
text: 'x Axis',
font: {
family: 'Courier New, monospace',
size: 18,
color: '#7f7f7f'
}
},
},
yaxis: {
title: {
text: 'y Axis',
font: {
family: 'Courier New, monospace',
size: 18,
color: '#7f7f7f'
}
}
},
height: 400,
width: 900
};
Plotly.newPlot(div, data,layout);

return div;
}
Insert cell
Insert cell
Insert cell
hawaii_comm_total_hawaiian_ = {
const hawaii_comm = modified_stats.filter(obj =>
obj.campus == "Hawai`i Community College");
const hawaii_comm_hawaiian = hawaii_comm.filter(obj =>
obj.hawaiian == 'HAWAIIAN');
let hawaii_comm_total_hawaiian = hawaii_comm_hawaiian.reduce((total, add) => {
let value = parseInt(add.enrollment)
total+= value;
return total
},0);
return hawaii_comm_total_hawaiian
}
Insert cell
hawaii_comm_total_hawaiian_non_ = {
const hawaii_comm = modified_stats.filter(obj =>
obj.campus == "Hawai`i Community College");
const hawaii_comm_hawaiian_non = hawaii_comm.filter(obj =>
obj.hawaiian != 'HAWAIIAN');
const hawaii_comm_total_hawaiian_non = hawaii_comm_hawaiian_non.reduce((total, add) => {
let value = parseInt(add.enrollment)
total+= value;
return total
},0);
return hawaii_comm_total_hawaiian_non
}
Insert cell
uni_manoa_total_hawaiian_non_ = {
const uni_manoa = modified_stats.filter(obj =>
obj.campus == "University of Hawai`i at Manoa");
const uni_manoa_hawaiian_non = uni_manoa.filter(obj =>
obj.hawaiian != 'HAWAIIAN');
const uni_manoa_total_hawaiian_non = uni_manoa_hawaiian_non.reduce((total, add) => {
let value = parseInt(add.enrollment)
total+= value;
return total
},0);
return uni_manoa_total_hawaiian_non
}
Insert cell
uni_manoa_total_hawaiian_ = {
const uni_manoa = modified_stats.filter(obj =>
obj.campus == "University of Hawai`i at Manoa");
const uni_manoa_hawaiian = uni_manoa.filter(obj =>
obj.hawaiian == 'HAWAIIAN');
let uni_manoa_total_hawaiian = uni_manoa_hawaiian.reduce((total, add) => {
let value = parseInt(add.enrollment)
total+= value;
return total
},0);
return uni_manoa_total_hawaiian
}
Insert cell
{

var data = [{
values: [hawaii_comm_total_hawaiian_, hawaii_comm_total_hawaiian_non_],
labels: ["Hawaiian","Non-Hawaiian"],
type: 'pie',
name: 'Honolulu Community College',
domain: {
row: 0,
column: 0
},
hoverinfo: 'label+percent+name',
textinfo: 'none'
},{
values: [uni_manoa_total_hawaiian_, uni_manoa_total_hawaiian_non_],
labels: ["Hawaiian","Non-Hawaiian"],
type: 'pie',
name: 'University of Hawaii at Manoa',
domain: {
row: 0,
column: 1
},
hoverinfo: 'label+percent+name',
textinfo: 'none'
}];

let layout = {
title: {
text:'Plot Title',
font: {
family: 'Courier New, monospace',
size: 24
},
xref: 'paper',
x: 0.05,
},
height: 400,
width: 1000,
grid: {rows: 1, columns: 2}
};

const div = DOM.element('div');

Plotly.newPlot(div,data,layout)
return div;
}
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