-
This is coming out stacked. How can I convert it to grouped? Changing encoding.column.field to "type" produces a grouped bar chart but the years all appear twice. {
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {"values":
[
{
"Year": 2002,
"Rentals": 184,
"VHS": 84
},
{
"Year": 2003,
"Rentals": 180,
"VHS": 67
}
]
},
"transform": [{
"fold": ["Rentals", "VHS"],
"as": ["type", "sales"]
}],
"mark": "bar",
"encoding": {
"x": {"field": "Year", "type": "ordinal"},
"y": {"field": "sales", "type": "quantitative"},
"color": {"field": "type", "type": "nominal"}
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
domoritz
Jun 9, 2021
Replies: 1 comment 5 replies
-
Open the Chart in the Vega Editor {
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {"values":
[
{
"Year": 2002,
"Rentals": 184,
"VHS": 84
},
{
"Year": 2003,
"Rentals": 180,
"VHS": 67
}
]
},
"transform": [{
"fold": ["Rentals", "VHS"],
"as": ["type", "sales"]
}],
"mark": "bar",
"encoding": {
"x": {"field": "type", "type": "ordinal"},
"y": {"field": "sales", "type": "quantitative"},
"color": {"field": "type", "type": "nominal"},
"column": {
"field": "Year", "type": "ordinal"
}
}
} Note: please use code fences, not |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
domoritz
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Open the Chart in the Vega Editor
Note: please use code fences, not
<code>
.