VegaLite({
data: {values: mathGradeArray},
"title": "Impact of workday alcohol consumption and absence on "+period,
"vconcat": [
{
"encoding": {
"tooltip": [
{"field": "sex", "type": "nominal"},
{"field": period, "type": "quantitative"}
],
"color": {
"condition": {
"title": "Mean of "+period,
"aggregate": "mean",
"field": period,
"scale": {
"domain": [0, 20]
},
"selection": "brush",
"type": "quantitative"
},
"value": "lightgray"
},
"x": {
"axis": {"title": "Workday alcohol consumption"},
"field": "Dalc",
"scale": {"domain": [0, 6]},
"type": "quantitative"
},
"y": {
"axis": {"title": "Weekend alcohol consumption"},
"field": "Walc",
"scale": {"domain": [0, 6]},
"type": "quantitative"
},
},
"width": 300,
"height": 300,
"mark": {"type": "circle"},
"selection": {"brush": {"type": "interval"}},
"transform": [{"filter": {"selection": "click"}}]
},
{
"encoding": {
"color": {
"condition": {
"field": period,
"selection": "click",
"type": "nominal"
},
"value": "lightgray"
},
"x": {"title": "Number of students", "aggregate": "count", "type": "quantitative"},
"y": {"title": period, "field": period, "bin": {"maxbins": 4}, "type": "nominal"}
},
"width": 600,
"mark": {"type": "bar"},
"selection": {"click": {"encodings": ["color"], "type": "multi"}},
"transform": [{"filter": {"selection": "brush"}}]
}
]
})