livebook-dev / vega_lite

Elixir bindings for Vega-Lite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Piping into VegaLite

joeybellerose opened this issue · comments

How hard would it be to add the ability to pipe a transformed DataFrame right into a VegaLite chart without needing to create intermediary variables?

My idea is something like this...

df
|> DataFrame.group_by(...)
|> DataFrame.summarise_with(...)
|> Vl.new()
|> Vl.mark()
|> Vl.encode_with(:x, "x")
|> Vl.encode_with(:y, "y")

...and the result is a chart in Livebook without any unnecessary variables.

Thoughts?

You could use then:

|> then(&Vl.data_from_values(Vl.new(), & &1)

But I would honestly not try to optimize for a single pipeline like that. Especially beicause between VegaLite and Explorer pipes it is a perfect opportunity for break. :)

Thanks for the pointer!

I'm still a little unclear on how combining the VegaLite and Explorer pipes it a perfect opportunity for a break.

Not that I'm trying to replicate exactly what happens in the R world, but doing things like this are fairly common practice.

Is there a resource I could check out to better understand the issues you're referring to?

Thanks in advance for all your help!

There is no issue per se, mostly that we don’t necessarily aim for full pipeability in Elixir. It is fine to sometimes break the pipeline and give things names by assigning them to variables. :)