TimeOfCrimes = VegaLite({
vconcat:[
{
width: 600,
height: 400,
layer: [{
data: {
values: VanAreas,
format: {
type: "topojson",
feature: "VancouverAreaSize"
}
},
projection: {
type: "mercator"
},
mark: "geoshape",
encoding: {
fill: {
field: "properties.density",
type: "quantitative",
title: "Density",
scale: {"scheme": "greys"}
},
stroke: {
value: "black"
},
tooltip: [
{field: "properties.NAME", title: "Name"},
{field: "properties.density", title: "#persons/500sqft"}
]
}
}, {
data: {
values: vanCrime2,
},
projection: {
type: "mercator"
},
mark: "circle",
transform: [
{filter: {selection: "brush"}}
],
encoding: {
longitude: {
field: "lng",
type: "quantitative",
},
latitude: {
field: "lat",
type: "quantitative"
},
size: {value: 12},
color: {
scale: {
domain: ['Non-vehicular', 'Vehicular'],
range: ['#ff0000', '#00aaff']
},
field: "Offense Type",
title: "Offense Type",
type: "nominal"
},
detail: {
field: "date",
type: "nominal"
},
tooltip: [
{field: "Offense Type", title: "Offense Type",type: "nominal"},
{field: "Offense", title: "Offense",type: "nominal"},
{field: "NEIGHBOURHOOD", title: "Neighbourhood", type: "nominal"},
{field: "Date", type: "nominal"}
]
}
}
]
}, {
width: 600,
height: 200,
data: {
values: vanCrime2,
},
selection: {
brush: { type: "interval", encodings: ["x"]}
},
mark: "line",
encoding: {
x: {timeunit: "monthday", field: "Date", type: "temporal"},
y: {aggregate: "count" , field: "*", type: "quantitative"},
color: {
field: "Offense Type",
title: "Offense Type",
scale: {
domain: ['Non-vehicular', 'Vehicular'],
range: ['#ff0000', '#00aaff']
}
}
}
}
]
})