viewof Graphs = VegaLite({
data: { values: data.unionByYear },
columns:2,
hconcat: [
{
title: "Relationship of Park Visits to Gas Prices",
width: 300,
height: 280,
transform: [
{filter: {field: "year", lte: range[1]}},
{filter: {field: "year", gte: range[0]}},
],
selection: {
area: { type: "interval" }
},
mark: { type: "circle", clip: true },
encoding: {
x: {
field: "gasPrice",
type: "quantitative",
scale: { domain: [1, d3.max(data.unionByYear, function(d) { return d.gasPrice; })]}
},
y: {
field: "parkVisits",
type: "quantitative",
aggregate:"sum",
axis: {title: "park visits"},
},
size: {
condition: {
selection: "area",
value: 20,
},
value: 5
},
color: {
condition: {
selection: "area",
value: "green",
},
value: "lightgray"
},
}
},
{
title: "Relationship of Park Visits to US Population",
width: 300,
height: 280,
transform: [
{filter: {field: "year", lte: range[1]}},
{filter: {field: "year", gte: range[0]}},
],
selection: {
area: { type: "interval" }
},
mark: { type: "circle", clip: true },
encoding: {
x: {
field: "population",
type: "quantitative",
scale: { domain: [80000000, d3.max(data.unionByYear, function(d) { return d.population; })]
}
},
y: {
field: "parkVisits",
type: "quantitative",
aggregate:"sum",
axis: {title: "park visits"},
scale: {
}
},
size: {
condition: {
selection: "area",
value: 20,
},
value: 5
},
color: {
condition: {
selection: "area",
value: "green",
},
value: "lightgray"
},
}
}
,
{
title: "Relationship of Park Visits to Number of Parks",
width: 300,
height: 280,
transform: [
{filter: {field: "year", lte: range[1]}},
{filter: {field: "year", gte: range[0]}},
],
selection: {
area: { type: "interval" }
},
mark: { type: "circle", clip: true },
encoding: {
y: {
field: "parkVisits",
type: "quantitative",
aggregate:"sum",
axis: {title: "park visits"},
scale: {
}
},
x: {
field: "numberOfParks",
type: "quantitative",
scale: {
}
},
size: {
condition: {
selection: "area",
value: 20,
},
value: 5
},
color: {
condition: {
selection: "area",
value: "green",
},
value: "lightgray"
},
}
},
{
title: "Percentage of Visitors for Each Park Type",
width: 300,
height: 280,
transform: [
{filter: {field: "year", lte: range[1]}},
{filter: {field: "year", gte: range[0]}},
],
selection: {
area: { type: "interval" }
},
mark: { type: "area", clip: true },
encoding: {
x: {field: "year", type: "quantitative"},
y: {field: "percentPerTypePerYear", type: "quantitative", aggregate:"mean", scale: {domain: [0,100]},
axis: {title: "percentage"}},
color: {field: "parkType", type: "nominal"}
}
}
,
{
title: "Relationship of Park Visits to the Year",
width: 300,
height: 280,
transform: [
{filter: {field: "year", lte: range[1]}},
{filter: {field: "year", gte: range[0]}},
],
mark: {
type: "line"
},
encoding: {
x: {
field: "year",
type: "quantitative"
},
y: {
field: "parkVisits",
type: "quantitative",
aggregate: "sum",
axis: {title: "park visits"},
},
color: {
field: "parkType",
type: "nominal"
}
}
},
{
title: "Relationship of Mean Park Visits to Gas Prices",
width: 300,
height: 280,
transform: [
{filter: {field: "year", lte: range[1]}},
{filter: {field: "year", gte: range[0]}},
],
mark: {
type: "line"
},
encoding: {
x: {
field: "year",
type: "quantitative"
},
y: {
field: "perTypePerYearRatioWithVisitor",
type: "quantitative",
axis: {title: "mean park visits"},
aggregate: "mean"
},
color: {
field: "parkType",
type: "nominal"
}
}
}
]
})