Skip to content

Instantly share code, notes, and snippets.

@nicolaskruchten
Created October 28, 2024 00:58
Show Gist options
  • Save nicolaskruchten/3a68755723a279af1939830ea6ded88a to your computer and use it in GitHub Desktop.
Save nicolaskruchten/3a68755723a279af1939830ea6ded88a to your computer and use it in GitHub Desktop.
final tax wheel
{
"$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": "radiusScale",
"type": "linear",
"domain": [1, 9],
"range": [0, {"signal": "radius"}]
}
],
"marks": [
{
"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/100, '0.3g')"},
"align": {"signal": "'right'"},
"baseline": {"value": "middle"},
"fontSize": {"value": 10},
"opacity": {"field": "opacity"},
"angle": {"signal": "(datum.angle * 180 / PI - 90)"}
}
}
},
{
"type": "text",
"from": {"data": "ticks"},
"encode": {
"enter": {
"x": {"signal": "width / 2"},
"y": {"signal": "height / 2"},
"radius": {"signal": "radius + 15"},
"theta": {"field": "angle2"},
"text": {"signal": "format(datum.value/100, '0.3g')"},
"align": {"signal": "'right'"},
"baseline": {"value": "middle"},
"fontSize": {"value": 10},
"opacity": {"field": "opacity"},
"angle": {"signal": "(datum.angle2 * 180 / PI - 90)"}
}
}
}
],
"data": [
{
"name": "ticks",
"transform": [
{"type": "sequence", "start": 100, "stop": 999, "step": 5},
{
"type": "formula",
"expr": "scale('angularScale', log(datum.data)/log(10))",
"as": "angle"
},
{
"type": "formula",
"expr": "scale('angularScale', log(datum.data)/log(10) - log(1.15)/log(10))",
"as": "angle2"
},
{"type": "formula", "expr": "datum.data", "as": "value"},
{
"type": "formula",
"expr": "(datum.value < 150 || (datum.value % 10 == 0 && datum.value <= 280) || (datum.value % 20 == 0 && datum.value <= 500)|| (datum.value % 25 == 0 && datum.value > 500 && datum.value <= 750) || (datum.value % 50 == 0 && datum.value > 750 ) ) ? 1 : 0",
"as": "opacity"
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment