I came across following vega-lite grammar example in the docs:
{
"data": {"url": "data/movies.json"},
"transform": [{
"sort": [{"field": "IMDB Rating"}],
"window": [{"op": "count", "field": "count", "as": "Cumulative Count"}],
"frame": [null, 0]
}],
"mark": "area",
"encoding": {
"x": {
"field": "IMDB Rating",
"type": "quantitative"
},
"y": {
"field": "Cumulative Count",
"type": "quantitative"
}
}
}
I am trying to generate the same plot using vega-lite-api.
I can do it as follows:
const plot = vl.markArea()
.data(data)
.transform(
{
"sort": [{"field": "IMDB Rating"}],
"window": [{"op": "count", "field": "count", "as": "Cumulative Count"}],
"frame": [null, 0]
}
)
.encode(
vl.x().fieldQ('IMDB Rating'),
vl.y().fieldQ('Cumulative Count')
)
return plot.toObject();
}
It generates the same cdf plot. I have following doubt:
Q. As you can see in above vega-lite-api code, I have specified following vega-lite grammar inside transform()
:
{
"sort": [{"field": "IMDB Rating"}],
"window": [{"op": "count", "field": "count", "as": "Cumulative Count"}],
"frame": [null, 0]
}
How can I do the same with pure vega-lite-api, using window()
API?