Skip to content

Instantly share code, notes, and snippets.

@PBI-DataVizzle
Created April 11, 2025 19:23
Show Gist options
  • Save PBI-DataVizzle/a1c1f10d25bbdba36c275a8e8b259c4e to your computer and use it in GitHub Desktop.
Save PBI-DataVizzle/a1c1f10d25bbdba36c275a8e8b259c4e to your computer and use it in GitHub Desktop.
container_column_chart
{
"$schema": "https://vega.github.io/schema/vega-lite/v6.json",
"datasets": {
"dataset": [
{"Country": "Canada", "Segment": "Channel Partners", "Sales": 19752468},
{"Country": "Canada", "Segment": "Enterprise", "Sales": 144752736},
{"Country": "Canada", "Segment": "Government", "Sales": 428829833},
{"Country": "Canada", "Segment": "Midmarket", "Sales": 21616940},
{"Country": "Canada", "Segment": "Small Business", "Sales": 361203792},
{"Country": "France", "Segment": "Channel Partners", "Sales": 15178124},
{"Country": "France", "Segment": "Enterprise", "Sales": 150182723},
{"Country": "France", "Segment": "Government", "Sales": 432792397},
{"Country": "France", "Segment": "Midmarket", "Sales": 25395919},
{"Country": "France", "Segment": "Small Business", "Sales": 274034856},
{"Country": "Germany", "Segment": "Channel Partners", "Sales": 9807620},
{"Country": "Germany", "Segment": "Enterprise", "Sales": 146362549},
{"Country": "Germany", "Segment": "Government", "Sales": 307773485},
{"Country": "Germany", "Segment": "Midmarket", "Sales": 12452545},
{"Country": "Germany", "Segment": "Small Business", "Sales": 281729079},
{"Country": "Mexico", "Segment": "Channel Partners", "Sales": 8887825},
{"Country": "Mexico", "Segment": "Enterprise", "Sales": 130960356},
{"Country": "Mexico", "Segment": "Government", "Sales": 413892255},
{"Country": "Mexico", "Segment": "Midmarket", "Sales": 16428775},
{"Country": "Mexico", "Segment": "Small Business", "Sales": 308830851},
{
"Country": "United States of America",
"Segment": "Channel Partners",
"Sales": 12059458
},
{
"Country": "United States of America",
"Segment": "Enterprise",
"Sales": 166894624
},
{
"Country": "United States of America",
"Segment": "Government",
"Sales": 362146299
},
{
"Country": "United States of America",
"Segment": "Midmarket",
"Sales": 21890524
},
{
"Country": "United States of America",
"Segment": "Small Business",
"Sales": 463176030
}
]
},
"width": 580,
"height": 360,
"title": {"text": "Country Revenue by Segment ($M)", "anchor": "start"},
"view": {"stroke": "transparent"},
"data": {"name": "dataset"},
"transform": [{"calculate": "datum.Sales / 1000000", "as": "Sales_M"}],
"layer": [
{
"encoding": {"y": {"field": "Sales", "aggregate": "sum"}},
"layer": [
{"mark": {"type": "bar", "color": "#d4d4d4"}},
{
"mark": {"type": "text", "baseline": "bottom", "dy": -15},
"encoding": {"text": {"field": "Country"}}
},
{
"mark": {"type": "text", "baseline": "top", "dy": -15},
"encoding": {
"text": {"field": "Sales_M", "aggregate": "sum", "format": ",d"}
}
}
]
},
{
"encoding": {
"y": {"field": "Sales"},
"xOffset": {
"field": "Segment",
"sort": {"field": "Sales", "order": "descending"},
"scale": {"padding": 0.2}
}
},
"layer": [
{
"mark": {"type": "bar", "stroke": "white"},
"encoding": {
"color": {
"field": "Segment",
"sort": {"field": "Sales", "order": "descending"},
"legend": {"orient": "top", "title": null}
}
}
},
{
"mark": {"type": "text", "dy": -7.5},
"encoding": {"text": {"field": "Sales_M", "format": ",d"}}
}
]
}
],
"encoding": {
"x": {
"field": "Country",
"sort": {"field": "Sales", "op": "sum", "order": "descending"},
"axis": null
},
"y": {"type": "quantitative", "axis": null}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment