ipydatagrid
ipydatagrid copied to clipboard
Use py2vega for the filtering/sorting actions?
@kaiayoung I can try to do it if that's fine with you
I have questions!
- Were you thinking of just adding support for vega expressions, or completely replacing the current sort/filter implementation? Vega transforms have a similar concept of transforms, but theirs supports inline vega expressions, which is interesting:
{
"data": [
{
"name": "table",
"transform": [
{ "type": "filter", "expr": "datum.value > 5" },
{ "type": "stack", "field": "value", "groupby": ["category"] }
]
}
]
}
It wouldn't be too difficult to extend our current implementation to support this, we would just add a new Transform.FilterByExpr interface ({type: "filter", expr: string, colIndex: number }) and a new TransformExecutor that just uses the provided vega expression as its filter function. We could even then add a "Filter by vega expr" item to the menu in addition to supporting it via grid.transform() on the widget.
-
How would you express a sort transform as a vega expression?
-
Can we modify the function created from parsing a vega expression? I'm mainly thinking of certain cases in which we may need to perform some transformation on the data prior to filtering, like ensuring that datetimes all have a timezone for comparison, etc.
I guess extending the current implementation is a good idea.
How would you express a sort transform as a vega expression?
Maybe a sorting function as a vega-expr?
Can we modify the function created from parsing a vega expression?
It might be difficult to change its implementation. But you would be able to change the arguments the vega-expr takes before executing it, which would solve your use case?