VegaLite({
data: {values: grantHeadcount.filter(function(f){return f.Sector == g})},
vconcat: [
{
mark: { type: "point",filled: "true"},
encoding: {
x: {timeUnit: "year", field: "Year", type: "temporal"},
y: {field: "AvgGrantPerStudent", type: "quantitative", aggregate:"sum"},
tooltip: [{field: "Year", timeUnit: "year", type:"temporal"}, {field: "Institution"}, {field: "AvgGrantPerStudent"}
],
color: {
condition: {
field: "Institution",
selection: "click",
scale: {scheme: "dark2"},
type: "nominal"
},
value: "lightgrey"
},
size: {field: "AvgGrantPerStudent", type: "quantitative"},
},
width: 500,
height: 500,
selection: {brush: {encodings: ["x"], type: "interval"}}
},
{
encoding: {
color: {
condition: {
field: "Institution",
selection: "click",
type: "nominal"
},
value: "lightgray"
},
x: {field:"AvgGrantPerStudent",aggregate: "sum", type: "quantitative"},
y: {field: "Sector", type: "nominal"},
tooltip: [{field: "Institution"}, {field:"AvgGrantPerStudent",aggregate: "sum", type: "quantitative" }
],
},
width: 500,
height:50,
mark: "bar",
selection: {click: {encodings: ["color"], type: "multi"}},
transform: [{filter: {selection: "brush"}}]
}
]
})