Forum Discussion
sean_cochran
Resolver I
2 years agoDeneb: implicitly calculated columns messing up x axis positioning for labels
I have a Deneb visual using vega lite. I used transforms to calculate a field for the x-axis position of labels (a text mark in the same layer object) hovering above bar marks - the field is called "...
- 2 years ago
Thanks for the response. I discovered that my problem was unrelated to the use of a window function. The extra columns are created when the "stack" property is enabled. I had it turned on while experimenting to solve an unrelated issue. When I set "stack" to "false", the additional columns disappeared, and labels were positioned absolutely (instead of relative to the _start and _end columns that were created by the "stack" property). I have not tried the cumulative sum function - that could be an elegant way of achieving the desired positioning. I found another way to achieve the desired result.
lbendlin
Super User
2 years agoHave you tried using sum instead of lag ?
"transform": [
{
"window": [
{
"op": "sum",
"field": "CU (s)",
"as": "cum_total"
}
],
"sort": [
{
"field": "CU (s)",
"order": "descending"
}
],
"frame": [null, 0]
},
{
"calculate": "datum.cum_total - datum['CU (s)'] + 2", "as": "bottomedge"
}]