Last active
March 10, 2023 14:05
-
-
Save ikiril01/ee14ecd00c4265ae4d554e46b75bcb8d to your computer and use it in GitHub Desktop.
Color Test
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", | |
| "background": "white", | |
| "padding": 5, | |
| "width": 400, | |
| "height": 300, | |
| "style": "cell", | |
| "data": [ | |
| { | |
| "name": "data-9794decafd64313e2c537fe6fc95bda8", | |
| "values": [ | |
| {"x": 2, "y": 2, "label": "B"}, | |
| {"x": 1, "y": 3, "label": "A"}, | |
| {"x": 3, "y": 2, "label": "C"}, | |
| {"x": 0.4, "y": 2, "label": "D"}, | |
| {"x": 0.4, "y": 2.5, "label": "E"} | |
| ] | |
| }, | |
| { | |
| "name": "data_0", | |
| "source": "data-9794decafd64313e2c537fe6fc95bda8", | |
| "transform": [ | |
| { | |
| "type": "filter", | |
| "expr": "isValid(datum[\"x\"]) && isFinite(+datum[\"x\"]) && isValid(datum[\"y\"]) && isFinite(+datum[\"y\"])" | |
| } | |
| ] | |
| }, | |
| { | |
| "name": "mapping", | |
| "values": [ | |
| {"domain": "A", "range": "#4daf4a"}, | |
| {"domain": "B", "range": "#984ea3"}, | |
| {"domain": "C", "range": "#ff7f00"}, | |
| {"domain": "G", "range": "#ffffff"} | |
| ] | |
| }, | |
| { | |
| "name": "mapping_filtered", | |
| "source": "data-9794decafd64313e2c537fe6fc95bda8", | |
| "transform": [ | |
| { | |
| "type": "aggregate", | |
| "groupby": [ | |
| {"field": "label", "as": "domain"}, | |
| {"field": "x", "as": "x"}, | |
| {"field": "y", "as": "y"} | |
| ] | |
| }, | |
| { | |
| "type": "lookup", | |
| "from": "mapping", | |
| "key": "domain", | |
| "fields": ["domain"], | |
| "values": ["range"], | |
| "default": "#a9a9a9" | |
| } | |
| ] | |
| } | |
| ], | |
| "marks": [ | |
| { | |
| "name": "marks", | |
| "type": "symbol", | |
| "style": ["point"], | |
| "from": {"data": "mapping_filtered"}, | |
| "encode": { | |
| "update": { | |
| "opacity": {"value": 0.7}, | |
| "fill": {"value": "transparent"}, | |
| "stroke": {"field": "range"}, | |
| "x": {"scale": "x", "field": "x"}, | |
| "y": {"scale": "y", "field": "y"}, | |
| "shape": {"scale": "shape", "field": "label"} | |
| } | |
| } | |
| } | |
| ], | |
| "scales": [ | |
| { | |
| "name": "x", | |
| "type": "linear", | |
| "domain": {"data": "data_0", "field": "x"}, | |
| "range": [0, {"signal": "width"}], | |
| "nice": true, | |
| "zero": true | |
| }, | |
| { | |
| "name": "y", | |
| "type": "linear", | |
| "domain": {"data": "data_0", "field": "y"}, | |
| "range": [{"signal": "height"}, 0], | |
| "nice": true, | |
| "zero": true | |
| }, | |
| { | |
| "name": "color", | |
| "type": "ordinal", | |
| "domain": {"data": "mapping_filtered", "field": "domain"}, | |
| "range": {"data": "mapping_filtered", "field": "range"} | |
| }, | |
| { | |
| "name": "shape", | |
| "type": "ordinal", | |
| "domain": {"data": "data_0", "field": "label", "sort": true}, | |
| "range": "symbol" | |
| } | |
| ], | |
| "axes": [ | |
| { | |
| "scale": "x", | |
| "orient": "bottom", | |
| "gridScale": "y", | |
| "grid": true, | |
| "tickCount": {"signal": "ceil(width/40)"}, | |
| "domain": false, | |
| "labels": false, | |
| "maxExtent": 0, | |
| "minExtent": 0, | |
| "ticks": false, | |
| "zindex": 0 | |
| }, | |
| { | |
| "scale": "y", | |
| "orient": "left", | |
| "gridScale": "x", | |
| "grid": true, | |
| "tickCount": {"signal": "ceil(height/40)"}, | |
| "domain": false, | |
| "labels": false, | |
| "maxExtent": 0, | |
| "minExtent": 0, | |
| "ticks": false, | |
| "zindex": 0 | |
| }, | |
| { | |
| "scale": "x", | |
| "orient": "bottom", | |
| "grid": false, | |
| "title": "x", | |
| "labelFlush": true, | |
| "labelOverlap": true, | |
| "tickCount": {"signal": "ceil(width/40)"}, | |
| "zindex": 0 | |
| }, | |
| { | |
| "scale": "y", | |
| "orient": "left", | |
| "grid": false, | |
| "title": "y", | |
| "labelOverlap": true, | |
| "tickCount": {"signal": "ceil(height/40)"}, | |
| "zindex": 0 | |
| } | |
| ], | |
| "legends": [ | |
| { | |
| "stroke": "color", | |
| "symbolType": "circle", | |
| "title": "label", | |
| "encode": { | |
| "symbols": { | |
| "update": { | |
| "fill": {"value": "transparent"}, | |
| "opacity": {"value": 0.7} | |
| } | |
| } | |
| } | |
| }, | |
| { | |
| "shape": "shape", | |
| "symbolType": "circle", | |
| "title": "label", | |
| "encode": { | |
| "symbols": { | |
| "update": { | |
| "fill": {"value": "transparent"}, | |
| "opacity": {"value": 0.7} | |
| } | |
| } | |
| } | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment