Public
Edited
Jun 1, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
ryanair_reviews.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {vl} from "@vega/vega-lite-api"
Insert cell
data = FileAttachment("ryanair_reviews.csv").csv()
Insert cell
// remove rows with null values
filteredData = data.filter(row => {
if(!row["Overall Rating"] || !row["Date Published"] || !row["Passenger Country"] || !row["Type Of Traveller"] || !row["Seat Type"] || !row["Origin"] || !row["Destination"] || !row["Date Flown"] || !row["Seat Comfort"] || !row["Cabin Staff Service"] || !row["Food & Beverages"] || !row["Ground Service"] || !row["Value For Money"] || !row["Recommended"]){
return false;
}
return true;
})

Insert cell
filteredLocationDataTemp = filteredData.filter((entry) => entry['Origin'].length >= 4 && entry['Destination'].length >= 4);
Insert cell
filteredLocationData = filteredLocationDataTemp.filter((entry) => !entry['Origin'].includes('/') && !entry['Origin'].includes(',') && !entry['Destination'].includes('/') && !entry['Destination'].includes(',') && !entry['Destination'].includes('via') && !entry['Destination'].includes('via') && !entry['Destination'].includes('(') && !entry['Destination'].includes('(') && !entry['Destination'].includes('.') && !entry['Destination'].includes(' and '));
Insert cell
workbook = FileAttachment("ryanair flight reviews CLEANED@4.xlsx").xlsx()
Insert cell
workbook.sheetNames
Insert cell
Insert cell
data1
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
Insert cell
// for pie charts: prepare ratings data based on icao
function getRatingsDataFromOriginICAO(originICAO){
//let overAllRatingKey = "Overall Rating";
let seatComfortKey = "Seat Comfort";
let cabinStaffServiceKey = "Cabin Staff Service";
let beveragesKey = "Food & Beverages";
let groundServiceKey = "Ground Service";
let valueForMoneyKey = "Value For Money";
// do wifi and entertainment??
let reducedData = data1.filter((row) => row["Origin (ICAO)"] === originICAO);

let preparedData = [seatComfortKey, cabinStaffServiceKey, beveragesKey, groundServiceKey, valueForMoneyKey].map((key) => ({
key,
values: reducedData.flatMap((row) => {
//if (key === overAllRatingKey) {
// normalize 1-10 to 1-5 to match other ratings
// return Math.round((row[key] / 10) * 5);
//}
return row[key];
})
}));
return preparedData;
}
Insert cell
// for pie charts: prepare ratings data based on icao
function getTypeOfTravellerOverallRatingFromOriginICAO(originICAO){
let overAllRatingKey = "Overall Rating";
let solo = "Solo Leisure";
let family = "Family Leisure";
let couple = "Couple Leisure";
let business = "Business";
let typeOfTravellerKey = "Type Of Traveller";
let reducedData = data1.filter((row) => row["Origin (ICAO)"] === originICAO);

let averageSolo = 0;
let averageFamily = 0;
let averageCouple = 0;
let averageBusiness = 0;
let sumSolo = 0;
let sumFamily = 0;
let sumCouple = 0;
let sumBusiness = 0;
for(let i = 0; i < reducedData.length; i ++){
if(reducedData[i][typeOfTravellerKey] === solo){
averageSolo += reducedData[i][overAllRatingKey];
sumSolo += 1;
}else if(reducedData[i][typeOfTravellerKey] === family){
averageFamily += reducedData[i][overAllRatingKey];
sumFamily += 1;
}else if(reducedData[i][typeOfTravellerKey] === couple){
averageCouple += reducedData[i][overAllRatingKey];
sumCouple += 1;
}else if(reducedData[i][typeOfTravellerKey] === business){
averageBusiness += reducedData[i][overAllRatingKey];
sumBusiness += 1;
}
}
averageSolo = (averageSolo / sumSolo).toFixed(2);
averageFamily = (averageFamily / sumFamily).toFixed(2);
averageCouple = (averageCouple / sumCouple).toFixed(2);
averageBusiness = (averageBusiness / sumBusiness).toFixed(2);

let preparedData = [{key: solo, value: averageSolo}, {key: family, value: averageFamily}, {key: couple, value: averageCouple}, {key: business, value: averageBusiness}].sort((a,b) => a.value - b.value);
return preparedData;
}
Insert cell
Insert cell
pieChart = PieChart(getRatingsDataFromOriginICAO("LEBL"), d3.schemeCategory10)
Insert cell
Insert cell
ryanAirColorScheme = ["#073590", "#F1C933", "#2091EB", "#AEB3BD"];
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
vl.markCircle({size:250})
.data(data)
.encode(
vl.x().fieldN('Passenger Country'),
vl.color().fieldQ('Overall Rating').scale({scheme: "reds"})
)
.render()
Insert cell
Insert cell
// Heatmap-Graph

/*vl.markBar()
.data(data)
.transform(
vl.filter('datum.Origin != ""')
)
.encode(
vl.x().fieldN('Origin'),
vl.y().fieldN('Destination'),
vl.color().count(),
vl.tooltip([
{
"field": "Origin",
"type": "nominal",
"title": "Origin"
},
{
"field": "Destination",
"type": "nominal",
"title": "Destination"
}]))
.render()*/
Insert cell
AptList = {
let aptList = [];
for (const d of data1) {
if (!aptList.includes({name: d["Origin (ICAO)"]}.name)) aptList.push({name: d["Origin (ICAO)"]}.name);
}
return aptList
}
Insert cell
viewof selOriApt = Inputs.search(AptList, {
datalist: AptList,
placeholder: "Origin Airport"
});
Insert cell
viewof selDestApt = Inputs.search(AptList, {
datalist: AptList,
placeholder: "Destination Airport"
});
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
fullscreenDashboard = fullscreen({
breakLayoutAtCell: 15,
hideAfter: 20,
show: 11,
left: 51,
right: 46,
button: html`<button style="background: steelblue; padding : 0.4em;border-radius: 0.2em; border-color: black;color: white; font-size: 16px; /*position:fixed;right:20px;top:0;*/">Enter Dashboard`
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
sketch_type = FileAttachment("sketch_type.jpg").image()
Insert cell
sketch_hover = FileAttachment("sketch_hover.jpg").image()
Insert cell
Insert cell
ryanairSketchForceLayout = FileAttachment("forceLayout@1.jpg").image()
Insert cell
ryanairSketchParallelSet = FileAttachment("Ryanair Sketch Parallel Set.jpg").image()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import { toc } from "@nebrius/indented-toc" // This component generates the Table of Contents
Insert cell
d3 = require("d3@7", "d3-sankey@0.12")
Insert cell
import {fullscreen} from "@pierreleripoll/vegasync"
Insert cell
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