Published
Edited
Apr 19, 2021
Insert cell
md`# Roller Coaster Assignment Copy`
Insert cell
md` ### Import Libraries`
Insert cell
import {vl} from '@vega/vega-lite-api'
Insert cell
d3 = require('d3')
Insert cell
import {printTable} from '@uwdata/data-utilities'
Insert cell
fileContents = FileAttachment("rollercoasters@1.csv")
Insert cell
df = d3.csvParse(await fileContents.text(), d3.autoType)
Insert cell
printTable(df.slice(0,5))
Insert cell
myviz = {

const nausea = vl.markPoint({size:90, filled:true})
.data(df)
.encode(
vl.x().fieldQ("excitement").axis({grid:false}).scale({domainMin:2}).title('Excitement'),
vl.y().fieldQ("nausea").title('Nausea'),
vl.color().fieldN("custom_design").legend(null),
vl.tooltip().fieldN('theme')
)
.width(400)
.height(200)

const intensity = vl.markPoint({size:90, filled:true})
.data(df)
.encode(
vl.x().fieldQ("excitement").axis(null).scale({domainMin:2}),
vl.y().fieldQ("intensity").title('Intensity'),
vl.color().fieldN("custom_design").legend(null),
vl.tooltip().fieldN('theme')
)
.width(400)
.height(200)

const speed = vl.markPoint({size:90, filled:true})
.data(df)
.encode(
vl.x().fieldQ("excitement").axis({grid:false}).scale({domainMin:2}).title('Excitement'),
vl.y().fieldQ("max_speed").title('Maximum Speed'),
vl.color().fieldN("custom_design").legend(null),
vl.tooltip().fieldN('theme')
)
.width(400)
.height(200)

const time = vl.markPoint({size:90, filled:true})
.data(df)
.encode(
vl.x().fieldQ("excitement").axis(null).scale({domainMin:2}),
vl.y().fieldQ("ride_time").title('Ride Time'),
vl.color().fieldN("custom_design").legend({orient:'top-left', fillColor:'white', labelFontSize: 12, titleFontSize:14, values:['Not Custom', 'Custom']}).title('Customization'),
vl.tooltip().fieldN('theme')
)
.width(400)
.height(200)

const horiz1 = vl.hconcat(time, intensity)

const horiz2 = vl.hconcat(speed, nausea)

return vl.vconcat(horiz1, horiz2)
.title({text:'Ride Time, Speed, Intensity, and Nausea Effect on Excitement Based on Custom or Not Custom Design', anchor: 'middle', fontSize:17, labelFontStyle:'bold'})

.render()

}
Insert cell
{
const base1 = vl.markPoint({opacity:0.5, filled:true})
.data(df)
.encode(
vl.x().fieldQ("intensity"),
vl.y().fieldQ("max_speed"),
vl.color().fieldN("rollercoaster_type"),
vl.size().fieldN('nausea_rating')
.scale({domain:['Low', 'Medium', 'High','Very High']})
)

const base2 = vl.markPoint({filled:true})
.data(df)
.encode(
vl.x().fieldQ("intensity"),
vl.y().fieldQ("max_speed"),
vl.color().fieldN("rollercoaster_type")
)
return vl.layer(base1, base2)
.width(700)
.height(200)
.title({text:'Intensity vs Speed vs Nausea', fontSize:14})
.render()
}
Insert cell
vl.markPoint({filled:true})
.data(df)
.encode(
vl.x().fieldQ("intensity"),
vl.y().fieldQ("max_speed"),
vl.color().fieldN("rollercoaster_type")
)

.width(700)
.height(200)
.title({text:'Intensity vs Speed vs Nausea', fontSize:14})
.render()

Insert cell
{
const base1 = vl.markPoint({opacity:0.3, filled:true})
.data(df)
.encode(
vl.x().fieldQ("intensity"),
vl.y().fieldQ("max_speed"),
vl.color().fieldN("custom_design"),
vl.size().fieldN('nausea_rating')
.scale({domain:['Low', 'Medium', 'High','Very High']})
)


const base2 = vl.markPoint({filled:true})
.data(df)
.encode(
vl.x().fieldQ("intensity"),
vl.y().fieldQ("max_speed"),
vl.color().fieldN("custom_design")
)
return vl.layer(base1, base2)

.width(700)
.height(200)
.title({text:'Intensity vs Speed vs Nausea', fontSize:14})
.render()
}
Insert cell
{
const base1 = vl.markPoint({opacity:0.3, filled:true})
.data(df)
.encode(
vl.x().fieldQ("excitement"),
vl.y().fieldQ("max_speed"),
vl.color().fieldN("custom_design"),
vl.size().fieldN('nausea_rating')
.scale({domain:['Low', 'Medium', 'High','Very High']})
)


const base2 = vl.markPoint({filled:true})
.data(df)
.encode(
vl.x().fieldQ("excitement"),
vl.y().fieldQ("max_speed"),
vl.color().fieldN("custom_design")
)
return vl.layer(base1, base2)

.width(700)
.height(200)
.title({text:'Excitement vs Speed vs Nausea', fontSize:14})
.render()
}
Insert cell
{
const base1 = vl.markPoint({opacity:0.3, filled:true})
.data(df)
.encode(
vl.x().fieldQ("excitement"),
vl.y().fieldQ("max_speed"),
vl.color().fieldN("custom_design"),
vl.size().fieldN('nausea')
.legend(null)
)


const base2 = vl.markPoint({filled:true})
.data(df)
.encode(
vl.x().fieldQ("excitement"),
vl.y().fieldQ("max_speed"),
vl.color().fieldN("custom_design")
)
return vl.layer(base1, base2)

.width(700)
.height(200)
.title({text:'Excitement vs Speed vs Nausea', fontSize:14})
.render()
}
Insert cell
{
const base1 = vl.markPoint({opacity:0.3, filled:true})
.data(df)
.encode(
vl.x().fieldQ("excitement"),
vl.y().fieldQ("nausea"),
vl.color().fieldN("custom_design"),
vl.size().fieldN('intensity')
.legend(null)
)


const base2 = vl.markPoint({filled:true})
.data(df)
.encode(
vl.x().fieldQ("excitement"),
vl.y().fieldQ("nausea"),
vl.color().fieldN("custom_design")
)
return vl.layer(base1, base2)

.width(700)
.height(200)
.title({text:'Excitement vs Nausea vs Intensity', fontSize:14})
.render()
}
Insert cell
vl.markPoint({opacity:0.5, filled:true})
.data(df)
.encode(
vl.x().fieldQ("excitement").axis({grid:false}).title('Excitement'),
vl.y().fieldQ("nausea").title('Nausea'),
vl.color().fieldN("custom_design").title('Customization'),
vl.size().fieldN('intensity_rating').title('Intensity')
.scale({domain:['Low', 'Medium', 'High','Very High']}),
vl.tooltip().fieldN('theme')
)

.width(700)
.height(200)
.title({text:'Nausea, Excitement, and Intensity on Custom and Not Custom Rollercoaster Designs', anchor:'middle', fontSize:16})
.render()
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more