Hi,
In below spec though same field (a_count) has been used for x-axis and text, text is shown correctly where as length of bars is incorrect (x-axis). May I pls know where the issue is?
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"width":600,
"height":500,
"data": {
"values": [
{"name": "a", "count": 3},
{"name": "b", "count": 3},
{"name": "b", "count": 3},
{"name": "e", "count": 3},
{"name": "e", "count": 3},
{"name": "e", "count": 3},
{"name": "g", "count": 1},
{"name": "g", "count": 1},
{"name": "a", "count": 3},
{"name": "b", "count": 3},
{"name": "b", "count": 3},
{"name": "e", "count": 3},
{"name": "e", "count": 3},
{"name": "e", "count": 3},
{"name": "g", "count": 1},
{"name": "g", "count": 1}
]
},
"transform": [
{
"joinaggregate": [{
"op": "count",
"field": "name",
"as": "b_count"
}],
"groupby": ["name"]
},
{
"joinaggregate": [{
"op": "distinct",
"field": "count",
"as": "no_count"
}]
},
{"calculate": "datum.b_count/datum.no_count", "as": "a_count"}
],
"encoding": {
"y": {"field": "name", "type": "nominal", "sort": "-x", "title": null},
"x": {"field": "a_count", "type": "quantitative", "title": null}
},
"layer": [
{
"mark": "bar",
"encoding": {
"color": {"field": "a_count", "type": "quantitative", "legend": null}
}
},
{
"mark": {
"type": "text",
"fontSize": 17,
"align": "left",
"dx": 5,
"aria": false
},
"encoding": {
"text": {"field": "a_count", "type": "quantitative"}
}
}
]
}
output :