Last active
March 24, 2021 06:51
-
-
Save tjws052009/2d5eb49feeb0ec08fb984cf1c2f3485c to your computer and use it in GitHub Desktop.
Vega experiment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://vega.github.io/schema/vega/v5.json", | |
"width": 500, | |
"height": 500, | |
"title": "Test heatmap", | |
"data": [ | |
{ | |
"name": "input", | |
"values": [ | |
{"x": 0, "y": 0, "val": 0}, | |
{"x": 0, "y": 1, "val": 1}, | |
{"x": 0, "y": 2, "val": 3}, | |
{"x": 1, "y": 0, "val": 0}, | |
{"x": 1, "y": 1, "val": 3}, | |
{"x": 1, "y": 2, "val": 3}, | |
{"x": 2, "y": 0, "val": 1}, | |
{"x": 2, "y": 1, "val": 4}, | |
{"x": 2, "y": 2, "val": 5} | |
] | |
} | |
], | |
"signals": [ | |
{"name": "rectwidth", "update": "width / 3"}, | |
{"name": "rectheight", "update": "height / 3"}, | |
{"name": "xrange", "update": "[0, width]"}, | |
{"name": "yrange", "update": "[height, 0]"} | |
], | |
"scales": [ | |
{ | |
"name": "xscale", | |
"type": "band", | |
"domain": {"data": "input", "field": "x"}, | |
"range": {"signal": "xrange"} | |
}, | |
{ | |
"name": "yscale", | |
"type": "band", | |
"domain": {"data": "input", "field": "y"}, | |
"range": {"signal": "yrange"} | |
}, | |
{ | |
"name": "color", | |
"domain": {"data": "input", "field": "val"}, | |
"type": "linear", | |
"range": {"scheme": "orangered"} | |
} | |
], | |
"axes": [ | |
{"scale": "xscale", "orient": "bottom", "tickMinStep": 1}, | |
{"scale": "yscale", "orient": "left", "tickMinStep": 1} | |
], | |
"marks": [ | |
{ | |
"type": "rect", | |
"from": {"data": "input"}, | |
"encode": { | |
"enter": { | |
"fill": {"scale": "color", "field": "val"}, | |
"x": {"scale": "xscale", "field": "x"}, | |
"y": {"scale": "yscale", "field": "y"} | |
}, | |
"update": { | |
"width": {"signal": "rectwidth"}, | |
"height": {"signal": "rectheight"} | |
} | |
} | |
}, | |
{ | |
"type": "text", | |
"from": {"data": "input"}, | |
"encode": { | |
"enter": { | |
"align": {"value": "center"}, | |
"baseline": {"value": "middle"}, | |
"text": {"field": "val"}, | |
"fontSize": {"value": 20}, | |
"x": {"scale": "xscale", "field": "x"}, | |
"y": {"scale": "yscale", "field": "y"}, | |
"dx": {"signal": "rectwidth / 2"}, | |
"dy": {"signal": "rectheight / 2"} | |
} | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://vega.github.io/editor/#/url/vega/N4IgJAzgxgFgpgWwIYgFwhgF0wBwqgegIDc4BzJAOjIEtMYBXAI0poHsDp5kTykSArJQBWENgDsQAGhAB3GgBN6aAQAZVM+DTJYV6mZjoAbOGhAAVOBEwACeEkzIc0kAocpUAbVDikCU+g04jgMmC7ESEYMVmjeIAAeaBogAJ5JMhFGSQC+UqCJqMlpqACMGZFoJbn56aloAEzlWagAzNUJlTLFyZk5eR2lXZ0gva3tBWV1qI0jFWP9BTPdTZXjDUODs80ALGvTGzOjAtkAuqcyENq+RhCxPn4BIABOcFCY8kowLgw4bpiPH3oNgINhaIHavn8Zheby0OjCMh+f0ecKwwNB4P6kMe8SeSHEZFMiN+Dkeng0NkBMBOmPuUPQKTxBKJICRpLMnlRmCkNlUNPOIGgkRiXjpOKFJhcmBSOEeTHxChcCjYyCCaFAfw8ICCIQRIAAZjQ4EZFehErlnvjCerBVc5gkmdbshCHmYUhKWdLZWZ5eJFTJlarJKgNe4zDrQi5DcbTXULY6AqBLmRrm6E+CXfSQFA2EY2E8lSqkGqQ64w4FgpGZNGTWZehavY8jEE4EgCzJ06WuIhHvmrXAXornScZEh4iK4h6zPEpzJ80bxGF0Ew2NgVVKaFAANYAWSCAGV-s5Su0pwzZyB53BF2YTPq9YZt3vxIe4MeqiOQMgnlvbqKQI20KvHq+pPOupaauGlZhBa145goiYgNe-wFqWhpGM0SZQMKZg5nm7YGkatboPWMgFFhOFmheNaxuaGwUZK57YZK1ZEbGaTOsSyI2lSNrJqm6Awu8ijKBaXJ8XazTPMB4nOpxoCAeg-zxCBYEIDakEVrqmJIeI8GIchA42pEVw2pk0S4YZBYWvKEDGi2ZmRBZ6AIIoCiSg2cAqTaNF1hUFr6hImD7jQABeiHmQE9SqBa5GCsx4oJVGbHTjpxQMY87pJaxMZujpChxfx9pCVS6L1Pl6W2imxUyXA2hoiC5Vyac2RAA