{
"background": "white",
"padding": 5,
"style": "cell",
"data": [
{"name": "highlight_store"},
{
"name": "source_0",
"values": [
{"actual": "A", "predicted": "A", "count": 13},
{"actual": "A", "predicted": "B", "count": 0},
{"actual": "A", "predicted": "C", "count": 0},
{"actual": "B", "predicted": "A", "count": 0},
{"actual": "B", "predicted": "B", "count": 10},
{"actual": "B", "predicted": "C", "count": 6},
{"actual": "C", "predicted": "A", "count": 0},
{"actual": "C", "predicted": "B", "count": 0},
{"actual": "C", "predicted": "C", "count": 9}
]
},
{
"name": "data_0",
"source": "source_0",
"transform": [
{"type": "identifier", "as": "_vgsid_"},
{
"type": "filter",
"expr": "isValid(datum[\"count\"]) && isFinite(+datum[\"count\"])"
}
]
}
],
"signals": [
{
"name": "signal_get_x_axis_label",
"value": "",
"on": [{"events": "@mark_x_axis_labels:click", "update": "datum.value"}]
},
{"name": "x_step", "value": 20},
{"name": "width", "update": "bandspace(domain('x').length, 0, 0) * x_step"},
{"name": "y_step", "value": 20},
{
"name": "height",
"update": "bandspace(domain('y').length, 0, 0) * y_step"
},
{
"name": "unit",
"value": {},
"on": [
{"events": "mousemove", "update": "isTuple(group()) ? group() : unit"}
]
},
{
"name": "highlight",
"update": "vlSelectionResolve(\"highlight_store\", \"union\", true, true)"
},
{
"name": "highlight_tuple",
"on": [
{
"events": [{"source": "scope", "type": "click"}],
"update": "datum && item().mark.marktype !== 'group' ? {unit: \"\", fields: highlight_tuple_fields, values: [(item().isVoronoi ? datum.datum : datum)[\"_vgsid_\"]]} : null",
"force": true
},
{"events": [{"source": "view", "type": "dblclick"}], "update": "null"}
]
},
{
"name": "highlight_tuple_fields",
"value": [{"type": "E", "field": "_vgsid_"}]
},
{
"name": "highlight_toggle",
"value": false,
"on": [
{
"events": [{"source": "scope", "type": "click"}],
"update": "event.shiftKey"
},
{"events": [{"source": "view", "type": "dblclick"}], "update": "false"}
]
},
{
"name": "highlight_modify",
"on": [
{
"events": {"signal": "highlight_tuple"},
"update": "modify(\"highlight_store\", highlight_toggle ? null : highlight_tuple, highlight_toggle ? null : true, highlight_toggle ? highlight_tuple : null)"
}
]
}
],
"marks": [
{
"name": "marks",
"type": "rect",
"style": ["rect"],
"interactive": true,
"from": {"data": "data_0"},
"encode": {
"update": {
"strokeWidth": {"value": 2},
"fill": {"scale": "fill", "field": "count"},
"stroke": [
{
"test": "length(data(\"highlight_store\")) && vlSelectionTest(\"highlight_store\", datum)",
"value": "black"
},
{"value": null}
],
"opacity": [
{
"test": "!length(data(\"highlight_store\")) || vlSelectionTest(\"highlight_store\", datum)",
"value": 1
},
{"value": 0.5}
],
"zindex": [
{
"test": "!length(data(\"highlight_store\")) || vlSelectionTest(\"highlight_store\", datum)",
"value": 1
},
{"value": 0}
],
"description": {
"signal": "\"actual: \" + (isValid(datum[\"actual\"]) ? datum[\"actual\"] : \"\"+datum[\"actual\"]) + \"; predicted: \" + (isValid(datum[\"predicted\"]) ? datum[\"predicted\"] : \"\"+datum[\"predicted\"]) + \"; count: \" + (format(datum[\"count\"], \"\"))"
},
"x": {"scale": "x", "field": "predicted"},
"width": {"scale": "x", "band": 1},
"y": {"scale": "y", "field": "actual"},
"height": {"scale": "y", "band": 1}
}
}
},
{
"type": "text",
"encode": {
"update": {
"x": {"value": 10},
"y": {"value": 50},
"text": {"signal": "signal_get_x_axis_label"},
"fontSize": {"value": 36},
"fill": {"value": "red"}
}
}
}
],
"scales": [
{
"name": "x",
"type": "band",
"domain": {"data": "data_0", "field": "predicted", "sort": true},
"range": {"step": {"signal": "x_step"}},
"paddingInner": 0,
"paddingOuter": 0
},
{
"name": "y",
"type": "band",
"domain": {"data": "data_0", "field": "actual", "sort": true},
"range": {"step": {"signal": "y_step"}},
"paddingInner": 0,
"paddingOuter": 0
},
{
"name": "fill",
"type": "linear",
"domain": {"data": "data_0", "field": "count"},
"range": "heatmap",
"interpolate": "hcl",
"zero": false
}
],
"axes": [
{
"scale": "x",
"orient": "top",
"grid": false,
"title": "predicted",
"labelAlign": "left",
"labelAngle": 270,
"labelBaseline": "middle",
"zindex": 1,
"encode": {
"labels": {
"name": "mark_x_axis_labels",
"interactive": true,
"update": {"fill": {"value": "blue"}},
"hover": {"fill": {"value": "red"}}
}
}
},
{
"scale": "y",
"orient": "left",
"grid": false,
"title": "actual",
"zindex": 1
}
],
"config": {
"range": {"ramp": {"scheme": "yellowgreenblue"}},
"axis": {"domain": false}
}
}