Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Summarize transform not working, but doesn't throw error #2910

Closed
1wiseash opened this issue Aug 22, 2017 · 3 comments
Closed

Summarize transform not working, but doesn't throw error #2910

1wiseash opened this issue Aug 22, 2017 · 3 comments

Comments

@1wiseash
Copy link

Hi,
Great project and very useful. Unfortunately, I have hit a road block. I can't seem to get summarize transforms to work. I have experimented with all manner of formats for the specification to make sure it isn't a simple user error (or try to convince myself of that anyway). The final spec (listed below) doesn't throw any errors, but doesn't work either.
I am basically trying to find the earliest time in each feature of a geojson file, then offset the other time fields using the feature's base time (converting to minutes also). Using a fixed value for base_time works to compute all the fields works fine ({"as": "base_time", "calculate": "1483228800000"}), so I am sure the subsequent calculations are encoded correctly. But when I try to use the summarize transform, all my other fields break, including fields that don't refer to base_time. The specification I have is below (leaving out the data, as it is very large).
Thanks in advance for your help.
-Ashley
{
"data": {...},
"transform": [
{
"filter": "datum.time > 0"
},
{
"filter": "datum.eta > 0"
},
{
"filter": "datum.sta > 0"
},
{
"summarize": [
{
"aggregate": "min",
"field": "time",
"as": "base_time"
}
],
"groupby": [
"feature_id"
]
},
{
"as": "time_offset_min",
"calculate": "(datum.time - datum.base_time) / 60000"
},
{
"as": "eta_offset_min",
"calculate": "(datum.eta - datum.base_time) / 60000"
},
{
"as": "sta_offset_min",
"calculate": "(datum.sta - datum.base_time) / 60000"
},
{
"as": "delay_min",
"calculate": "datum.eta_offset_min - datum.sta_offset_min"
}
],
"mark": {
"type": "circle",
"filled": true
},
"width": 300,
"height": 225,
"encoding": {
"color": {
"value": "#202c40"
},
"x": {
"field": "time_offset_min",
"type": "quantitative",
"scale": {
"zero": false,
"type": "linear"
}
},
"y": {
"field": "eta_offset_min",
"type": "quantitative",
"scale": {
"zero": false,
"type": "linear"
}
}
}
}
Probably not useful, but I'm proud of what I'm building, so here is a screenshot of it.
image

@kanitw
Copy link
Member

kanitw commented Aug 22, 2017

Thanks for reporting. Summarize transform actually generates a new data table (akin to an aggregate query in SQL).

What you want to do here is augmenting existing data table new a new summary column.
This could be done using the window transform in Vega, but we have not implemented it in Vega-Lite yet. (See #2488.)

As we're still revising the documentation for the 2.0 release, I'll note to make sure we make this clearer in the docs (#2279).

@kanitw kanitw closed this as completed Aug 22, 2017
@kanitw kanitw mentioned this issue Aug 22, 2017
1 task
@1wiseash
Copy link
Author

Thanks for your quick response. So, if I am reading it correctly, I can't do what I need directly in VL; I have to add the summary data to my dataset before using it to create the chart. Sorry if that is obvious. I just want to be sure before creating the pre-processing workaround.
Thanks again!
-Ashley

@kanitw
Copy link
Member

kanitw commented Aug 23, 2017

Yes, you cannot do it directly in VL yet. Once #2488 is implemented, then you can. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants