Files
minivlat-local-ua/public/charts/stackedbarchart-original.vl.json
2025-01-30 16:28:56 +02:00

97 lines
1.8 KiB
JSON

{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"title": {
"text": "Room Service Prices"
},
"data": {
"url": "data/stackedbarchart.csv"
},
"width": 600,
"height": 400,
"encoding": {
"x": {
"field": "City",
"type": "nominal",
"axis": {
"title": "Cities",
"labelAngle": 40,
"titleFontWeight": "bold"
}
},
"y": {
"field": "value",
"type": "quantitative",
"axis": {
"title": "Cost ($)",
"titleFontWeight": "bold",
"grid": true,
"gridDash": [1, 0],
"tickCount": 15
},
"scale": {
"domain": [
0,
70
]
}
},
"color": {
"field": "category",
"type": "nominal",
"scale": {
"domain": [
"Vodka",
"Soda",
"Peanut",
"Water",
"Sandwich"
],
"range": [
"#386cb0",
"#7fc97f",
"#beaed4",
"#fdc086",
"#fb9a99"
]
},
"legend": {
"title": null,
"orient": "right"
}
},
"order": {
"field": "order",
"type": "quantitative",
"sort": "descending"
}
},
"mark": "bar",
"transform": [
{
"fold": [
"Sandwich",
"Water",
"Peanut",
"Soda",
"Vodka"
],
"as": [
"category",
"value"
]
},
{
"calculate": "datum.category === 'Vodka' ? 1 : datum.category === 'Soda' ? 2 : datum.category === 'Peanut' ? 3 : datum.category === 'Water' ? 4 : 5",
"as": "order"
}
],
"config": {
"axis": {
"grid": true,
"gridColor": "#ddd"
},
"view": {
"stroke": null
}
}
}