spec = ({
"$schema": "https://vega.github.io/schema/vega/v4.json",
"width": 360,
"height": 320,
"padding": 5,
"data": [
{
"name": "words",
"values": data,
"transform":[{"type": "flatten", "fields": ["econs", "gcons", "pairs"]},
{"type": "filter", "expr": "datum.english == word"}]
}
],
"signals": [{
"name": "word",
"value": "Water",
"bind": {
"input": "select",
"name": "Select a word pair to compare: ",
"options": ["Water","Nose","Death","Ear","Two","Eye","Four","Hand","I","Name","Night","Thou","Sun","Three","Tongue","Tooth","Who","Wind"]
}
} ],
"scales": [
{
"name": "xscale",
"type": "band",
"domain": {"data": "words", "field": "econs"},
"range": "width",
"padding": 0.05,
"round": true
},
{
"name": "gxscale",
"type": "band",
"domain": {"data": "words", "field": "gcons"},
"range": "width",
"padding": 0.05,
"round": true
},
{
"name": "yscale",
"type": "linear",
"domain": [0, 100],
"padding": 0.05,
"range": "height"
}
],
"axes": [
{ "orient": "bottom", "scale": "xscale", "title": "English Consonants"},
{ "orient": "top", "scale": "gxscale", "title": "German Consonants"},
{ "orient": "left", "scale": "yscale", "title": "Consonant Similarity (distant to matching)" }
],
"marks": [
{
"type": "rect",
"from": {"data":"words"},
"encode": {
"enter": {},
"update":{
"x": {"scale": "xscale", "field": "econs"},
"width": {"scale": "xscale", "band": 1},
"y": {"scale": "yscale", "field": "pairs"},
"y2": {"scale": "yscale", "value": 0},
"fill": {"value": "cornflowerblue"},
"stroke": {"value": "navy"}
}
}}
]
})