SummaryTable(data)//blue means ordinal. ordinal means not continous aka strings
data_autoTyped=FileAttachment("temperature.csv").csv({typed:true})//we do typed:true so that java does its so-called magic and guesses that the date section is a date form rather than a string form
Inputs.table(data_autoTyped)//note that a convention in maths is for strings to go on right side aka data and numbers aka temperature is on left column
SummaryTable(data_autoTyped)
data_autoTyped[0].date.constructor.name
data_autoTyped[0].temperature.constructor.name
parseTime=d3.timeParse("%Y-%m-%d")//this parseTime is not a function. we are just configuring the function to interpret the date in that specific way. github tells us %Y means year, %m means month etc. we put the - dash in between each to look for our dash seperator
parseTime("2011-11-02")//this is Java's stupidity which we have to deal with because if you put 11 in the code it shows month 10 because for some reason java makes months start at 0 and day start at 0
//we use then because it becomes faster. and for csv files we MUST put .then
data.forEach((d)=>{
d.date=parseTime(d.date);
d.temperature=Number(d.temperature)/1.8-32;
// ... convert dates from string to Date object
// ... convert temperature from Fahrenheit to Celsius. Formula: (fahrenheit-1.8)/32
//Note to professor: the formula is actually (fahrenheit-32)/1.8 as far as I checked. I still used the wrong formula though to replicate the picture below for my table
});
returndata;
})
Inputs.table(data_manuallyTyped)
SummaryTable(data_manuallyTyped)
imageToDo
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.