Published
Edited
Sep 27, 2019
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//this section is by Theo
Insert cell
minHP = d3.min(data2017, d => d["Engine HP"]); //minimum HP of all cars in 2017
Insert cell
maxHP = d3.max(data2017, d => d["Engine HP"]); //maximum HP of all cars in 2017
Insert cell
minEngineCyl = d3.min(data2017, d => d["Engine Cylinders"]); //least amount of cylinders of all cars in 2017; 0 represents Electric cars
Insert cell
maxEngineCyl = d3.max(data2017, d => d["Engine Cylinders"]); //most amount of cylinders of all cars in 2017
Insert cell
minDoors = d3.min(data2017, d => d["Number of Doors"]); //minimum number of doors of all cars in 2017
Insert cell
maxDoors = d3.max(data2017, d => d["Number of Doors"]); //maximum number of doors of all cars in 2017
Insert cell
minHwyMPG = d3.min(data2017, d => d["highway MPG"]); //minimum highway miles per gallon (MPG) of all cars in 2017
Insert cell
maxHwyMPG = d3.max(data2017, d => d["highway MPG"]); //maximum highway MPG of all cars in 2017//this section is by David
Insert cell
minCityMPG = d3.min(data2017, d => d["city mpg"]); //minimum city MPG of all cars in 2017
Insert cell
maxCityMPG = d3.max(data2017, d => d["city mpg"]); //maximum city MPG of all cars in 2017
Insert cell
minPop = d3.min(data2017, d => d.Popularity); //least popular rating of all cars in 2017
Insert cell
maxPop = d3.max(data2017, d => d.Popularity); //most popular rating of all cars in 2017
Insert cell
minMSRP = d3.min(data2017, d => d.MSRP); //cheapest price of all cars in 2017
Insert cell
maxMSRP = d3.max(data2017, d => d.MSRP); //most expensive price of all cars in 2017
Insert cell
Insert cell
Insert cell
//this section is by David
Insert cell
Insert cell
Insert cell
meanMSRP = d3.mean(data2017, d => d.MSRP); //average = $70,375,479 / 1668 cars
Insert cell
Insert cell
meanEngineHP = d3.mean(data2017, d => d["Engine HP"]); //average = 453664 (sum of HP) / 1653 cars (some cars do not have recorded data)
Insert cell
Insert cell
meanHMPG = d3.mean(data2017, d => d["highway MPG"]); //average = 47667 HMPG / 1668 cars
Insert cell
Insert cell
meanCMPG = d3.mean(data2017, d => d["city mpg"]); //average = 35569 CMPG / 1668 cars
Insert cell
Insert cell
Insert cell
//this section is by Theo
Insert cell
Insert cell
Insert cell
acuraHPAboveAvg = acuraData.filter(d => d["Engine HP"] >= meanEngineHP);
Insert cell
acuraMSRPAboveAvg = acuraData.filter(d => d.MSRP >= meanMSRP);
Insert cell
Insert cell
//this section is by David
Insert cell
Insert cell
bmwCMPGAboveAvg = bmwData.filter(d => d["city mpg"] >= meanCMPG);
Insert cell
bmwHMPGAboveAvg = bmwData.filter(d => d["highway MPG"] >= meanHMPG);
Insert cell
bmwMSRPAboveAvg = bmwData.filter(d => d.MSRP >= meanMSRP);
Insert cell
bmw_MSRP_HMPG_CMPG_AboveAvg = bmwData.filter(function(d) {
return (d.MSRP >= meanMSRP &&
d["city mpg"] >= meanCMPG &&
d["highway MPG"] >= meanHMPG
)
});
Insert cell
Insert cell
//this section is by Theo
Insert cell
twoDoorCarAvgMSRP = data2017.filter(function(d) {
return (d["Number of Doors"] == 2 &&
d.MSRP >= meanMSRP
)
});
Insert cell
fourDoorCarAvgMSRP = data2017.filter(function(d) {
return (d["Number of Doors"] == 4 &&
d.MSRP >= meanMSRP
)
});
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//this section is by David
Insert cell
//we chose to implement a slider for this histogram because it allows us to see the data from a general point of view to a more zoomed in point of view
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//we chose to use a slider for the bin size because it allowed us to see general highs and lows in data, then be able to take a closer look at specific data regions
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//this section is by Theo
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
Insert cell
Insert cell
//we chose to have a fixed bin size of 5000 because it allowed us to show the maximum and minimum highway MPG for each make of car

//for the y axis of the graph we have so many categories due to the number of manufactures for cars there are
Insert cell
Insert cell
Insert cell
//this section is by David
Insert cell
Insert cell
//we chose to have a fixed bin size because it allowed us to show the minimum and maximum city MPG for each make of car
Insert cell
Insert cell
Insert cell
Insert cell
//a fixed bin size was used because it allowed us to best demonstrate the minimum and maximum average values of MSRP for each make of car
Insert cell
Insert cell
Insert cell
Insert cell
//we chose to limit the bin size for this graph because we wanted to see the average popularity at the lowest, highest and all the values in between
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//https://gist.githubusercontent.com/tdore98/fc20a7d8472fd73932cd9abd907927df/raw/8e9aa9e157b67197a57c80b93b669c72411e8850/data.csv
Insert cell
//the remaining sections are done collaboratively by Theo and David
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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