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

Data module #49

Merged
merged 29 commits into from
Aug 1, 2023
Merged

Conversation

cristineguadelupe
Copy link
Contributor

@cristineguadelupe cristineguadelupe commented Jul 27, 2023

Short hand api and specialized charts

guides/data.livemd Outdated Show resolved Hide resolved
guides/data.livemd Outdated Show resolved Hide resolved
lib/vega_lite/data.ex Outdated Show resolved Hide resolved
lib/vega_lite/data.ex Outdated Show resolved Hide resolved
lib/vega_lite/data.ex Outdated Show resolved Hide resolved
guides/data.livemd Outdated Show resolved Hide resolved
guides/data.livemd Outdated Show resolved Hide resolved
guides/data.livemd Outdated Show resolved Hide resolved
lib/vega_lite/data.ex Outdated Show resolved Hide resolved
lib/vega_lite/data.ex Outdated Show resolved Hide resolved
lib/vega_lite/data.ex Outdated Show resolved Hide resolved
lib/vega_lite/data.ex Outdated Show resolved Hide resolved
lib/vega_lite/data.ex Outdated Show resolved Hide resolved
@cristineguadelupe cristineguadelupe marked this pull request as ready for review July 31, 2023 15:14
```elixir
# A line plot with point: true using the shorthand api
Data.chart(fuels, [type: :line, point: true], x: "total", y: "solid_fuel")
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the Data example comes last, but in the previous example the Data example comes first. Should we make it consistent?

lib/vega_lite/data.ex Outdated Show resolved Hide resolved
lib/vega_lite/data.ex Outdated Show resolved Hide resolved
# Piping the shorthand api into a enconde_field
Vl.new(width: 500, height: 300, title: "Fuels")
|> Data.chart(fuels, :point, x: "total", y: "solid_fuel")
|> Vl.encode_field(:color, "total", type: :quantitative, scale: [scheme: "category10"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an issue in this approach. This code only works because both x and color use "total". But if the color was encoded with another value, then its field would not be included in only. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! We rely on Table.Reader, so it might be better to remove the implicit only and allow passing it as an option of the data argument. Or maybe make it implicit by default and use the option to override it. 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can have one option called additional_fields or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer only for consistency, like in values_from

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Data.chart([data: fuels, only: …], :point, x: "total", y: "solid_fuel")
And that should be the only argument accepted for data

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you said nothing about having or not a default…

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a default, for sure. But I was wondering if we could have that as part of fields somehow:

Data.chart(fuels, :point, x: "total", y: "solid_fuel", additional_fields: [:foo, :bar])

Another idea is to move the logic VegaLite itself. We could support only: :lazy and then we compute it the time we build the JSON.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge this without tackling this problem and please open up an issue so we do it next. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok!

cristineguadelupe and others added 8 commits August 1, 2023 05:36
Co-authored-by: José Valim <jose.valim@gmail.com>
Co-authored-by: José Valim <jose.valim@gmail.com>
Co-authored-by: José Valim <jose.valim@gmail.com>
Co-authored-by: José Valim <jose.valim@gmail.com>
Co-authored-by: José Valim <jose.valim@gmail.com>
lib/vega_lite/data.ex Outdated Show resolved Hide resolved
lib/vega_lite/data.ex Outdated Show resolved Hide resolved
lib/vega_lite/data.ex Outdated Show resolved Hide resolved
Copy link
Contributor

@josevalim josevalim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some final nitpicks. We can handle the :only separately. :)

cristineguadelupe and others added 4 commits August 1, 2023 17:57
Co-authored-by: José Valim <jose.valim@gmail.com>
Co-authored-by: José Valim <jose.valim@gmail.com>
Co-authored-by: José Valim <jose.valim@gmail.com>
@cristineguadelupe cristineguadelupe merged commit 518d1d1 into livebook-dev:main Aug 1, 2023
2 checks passed
@cristineguadelupe cristineguadelupe deleted the cg-stats branch August 1, 2023 12:25
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

Successfully merging this pull request may close these issues.

3 participants