Last active
October 27, 2024 21:26
-
-
Save nicolaskruchten/6b366d455a47b051cb8b89210aea220a to your computer and use it in GitHub Desktop.
tax wheel
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": 400, | |
"height": 400, | |
"signals": [ | |
{"name": "radius", "value": 150} | |
], | |
"scales": [ | |
{ | |
"name": "angularScale", | |
"type": "linear", | |
"domain": [0, 1], | |
"range": [0, 6.28318] | |
}, | |
{ | |
"name": "angularScale2", | |
"type": "linear", | |
"domain": [0, 1], | |
"range": [0, 6.28318] | |
}, | |
{ | |
"name": "radiusScale", | |
"type": "linear", | |
"domain": [1, 9], | |
"range": [0, {"signal": "radius"}] | |
} | |
], | |
"marks": [ | |
{ | |
"type": "arc", | |
"from": {"data": "ticks"}, | |
"encode": { | |
"enter": { | |
"x": {"signal": "width / 2"}, | |
"y": {"signal": "height / 2"}, | |
"startAngle": {"field": "angle"}, | |
"endAngle": {"field": "angle"}, | |
"outerRadius" : {"signal": "radius"}, | |
"innerRadius" : {"signal": "radius - ((datum.value % 0.5 == 0 ) ? 10 : (datum.value % 0.25 == 0 ) ? 7 : 4)"}, | |
"stroke": {"value": "black"}, | |
"strokeWidth": {"value": 1} | |
} | |
} | |
}, | |
{ | |
"type": "text", | |
"from": {"data": "ticks"}, | |
"encode": { | |
"enter": { | |
"x": {"signal": "width / 2"}, | |
"y": {"signal": "height / 2"}, | |
"radius": {"signal": "radius - 15"}, | |
"theta": {"field": "angle"}, | |
"text": {"signal": "format(datum.value, '.3g')"}, | |
"align": {"signal": "'right'"}, | |
"baseline": {"value": "middle"}, | |
"fontSize": {"value": 10}, | |
"opacity": {"signal": "(datum.value < 2 || datum.value % 0.25 == 0 ) ? 1 : 0"}, | |
"angle": { | |
"signal": "(datum.angle * 180 / PI - 90)" | |
} | |
} | |
} | |
}, | |
{ | |
"type": "arc", | |
"from": {"data": "ticks2"}, | |
"encode": { | |
"enter": { | |
"x": {"signal": "width / 2"}, | |
"y": {"signal": "height / 2"}, | |
"startAngle": {"field": "angle"}, | |
"endAngle": {"field": "angle"}, | |
"outerRadius" : {"signal": "radius + ((datum.value % 0.5 == 0 ) ? 10 : (datum.value % 0.25 == 0 ) ? 7 : 4)"}, | |
"innerRadius" : {"signal": "radius"}, | |
"stroke": {"value": "black"}, | |
"strokeWidth": {"value": 1} | |
} | |
} | |
}, | |
{ | |
"type": "text", | |
"from": {"data": "ticks2"}, | |
"encode": { | |
"enter": { | |
"x": {"signal": "width / 2"}, | |
"y": {"signal": "height / 2"}, | |
"radius": {"signal": "radius + 15"}, | |
"theta": {"field": "angle"}, | |
"text": {"signal": "format(datum.value, '.3g')"}, | |
"align": {"signal": "'left'"}, | |
"baseline": {"value": "middle"}, | |
"fontSize": {"value": 10}, | |
"opacity": {"signal": "(datum.value < 2 || datum.value % 0.25 == 0 ) ? 1 : 0"}, | |
"angle": { | |
"signal": "(datum.angle * 180 / PI - 90)" | |
} | |
} | |
} | |
} | |
], | |
"data": [ | |
{ | |
"name": "ticks", | |
"transform": [ | |
{"type": "sequence", "start": 1, "stop": 9.999, "step": 0.05}, | |
{ | |
"type": "formula", | |
"expr": "scale('angularScale', log(datum.data)/log(10))", | |
"as": "angle" | |
}, | |
{"type": "formula", "expr": "datum.data", "as": "value"} | |
] | |
}, | |
{ | |
"name": "ticks2", | |
"transform": [ | |
{"type": "sequence", "start": 1 , "stop": 9.999, "step": 0.05}, | |
{ | |
"type": "formula", | |
"expr": "scale('angularScale2', log(datum.data)/log(10) - log(1.15)/log(10))", | |
"as": "angle" | |
}, | |
{"type": "formula", "expr": "datum.data", "as": "value"} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment