ipydatagrid icon indicating copy to clipboard operation
ipydatagrid copied to clipboard

Use py2vega for the filtering/sorting actions?

Open martinRenou opened this issue 6 years ago • 2 comments
trafficstars

@kaiayoung I can try to do it if that's fine with you

martinRenou avatar Oct 01 '19 06:10 martinRenou

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.

kaiayoung avatar Oct 01 '19 14:10 kaiayoung

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?

martinRenou avatar Oct 01 '19 15:10 martinRenou