Open Ying456123 opened 5 years ago
Now I found using fold transformation can give me the expected result, but seems like Vegas doesn't support it now. Below is my Vega-lite's script and result:
{
"$schema": "https://vega.github.io/schema/vega-lite/v3.json",
"description": "A bar chart showing the US population distribution of age groups and gender in 2000.",
"data": {
"values": [
{
"col": "row1",
"data1": 28,
"data2":30
},
{
"col": "row2",
"data1": 47,
"data2":105
},
{
"col": "row3",
"data1": 71,
"data2":177
}
]
},
"transform": [{"fold": ["data1", "data2"]}],
"mark":"bar",
"encoding":{
"x":{"field":"col", "type":"nominal"},
"y": {"field": "value", "type": "quantitative"},
"color":{"field":"key","type":"nominal"}
}
}
result:
Hi, Sorry to ask as a new user. When I want to compare two columns with layers, I cannot encode color with two columns. Even if I add the encodeColor on the second layer, it doesn't behave as I expected. Below is original code:
After I add the encodeColor on second layer, it behaves as below:
The result: Could anyone help? Thanks a lot.