Skip to content

Instantly share code, notes, and snippets.

@cbaragao
Created September 17, 2025 01:37
Show Gist options
  • Select an option

  • Save cbaragao/1f57abc2a846875109ef434868120cc3 to your computer and use it in GitHub Desktop.

Select an option

Save cbaragao/1f57abc2a846875109ef434868120cc3 to your computer and use it in GitHub Desktop.
{
"data": {
"name": "dataset"
},
"title": {
"text": "Top Sales by Product",
"font": "Roboto",
"fontSize": 20,
"color": "black"
},
"transform": [
{
"calculate": "5",
"as": "text_x"
}
],
"encoding": {
"x": {
"field": "Sum of Sales",
"type": "quantitative",
"axis": null
},
"y": {
"field": "Product",
"type": "nominal",
"sort": "-x",
"axis": {
"title": null,
"ticks": false,
"domain": false,
"bandPosition": 0,
"labels": false
}
},
"color": {
"value": "#2E4057"
},
"opacity": {
"condition": {
"test": {
"field": "__selected__",
"equal": "off"
},
"value": 0.3
},
"value": 1
}
},
"layer": [
{
"mark": {
"type": "bar",
"cornerRadiusTopRight": 5,
"cornerRadiusBottomRight": 5,
"height": 25
}
},
{
"mark": {
"type": "text",
"align": "left",
"dx": 5,
"fontSize":14
},
"encoding": {
"x": {
"field": "text_x",
"type": "quantitative"
},
"y": {
"field": "Product",
"type": "nominal"
},
"text": {
"field": "Product",
"type": "nominal"
},
"color": {
"value": "white"
}
}
},
{
"mark": {
"type": "text",
"align": "left",
"dx": 3,
"fontSize":14
},
"encoding": {
"x": {
"field": "Sum of Sales",
"type": "quantitative"
},
"y": {
"field": "Product",
"type": "nominal"
},
"text": {
"field": "Sum of Sales",
"type": "quantitative",
"format": ".2s"
},
"color": {
"value": "black"
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment