Skip to content

Data module #49

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

Merged
29 commits merged into from Aug 1, 2023
Merged

Data module #49

29 commits merged into from Aug 1, 2023

Conversation

ghost
Copy link

@ghost ghost commented Jul 27, 2023

Short hand api and specialized charts

@ghost ghost requested a review from josevalim July 27, 2023 13:32
@ghost ghost 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?

# 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
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
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
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
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
Author

Choose a reason for hiding this comment

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

Ok!

@ghost ghost mentioned this pull request Aug 1, 2023
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. :)

Cristine Guadelupe and others added 4 commits August 1, 2023 17:57
@ghost ghost merged commit 518d1d1 into livebook-dev:main Aug 1, 2023
@ghost ghost deleted the cg-stats branch August 1, 2023 12:25
This pull request was closed.
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.

2 participants