-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Refactor vega-related charting #8595
Conversation
|
||
return self.dg._enqueue( | ||
"arrow_area_chart", proto, add_rows_metadata=add_rows_metadata | ||
return self._altair_chart( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it might be a good idea to leave a small comment about how Vega and Altair belong together, because the class is called VegaChartsMixin
but then here we return an altair_chart
. This could be confusing to people who do not know about these projects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a docstring comment to the VegaChartsMixin class to explain how the commands are related 👍
out_data: Data | ||
|
||
# For some delta types we have to reshape the data structure | ||
# For built-in chart commands we have to reshape the data structure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: if this function is only relevant for chart commands but not generally for everything that uses arrow / add-row functionality as the comment says, I suggest to rename the function to sth. like _prep_chart_data_for_add_rows
and perhaps move it to the new built_in_chart_utils.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot easily fully move this method since its used in all add row cases, but I extracted the chart specific logic to built_in_charts_utils
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alrighty, but is this function only relevant for chart types or in general?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The migrated part is only relevant for built-in charts, but _prep_data_for_add_rows
is called in all add row cases.
color_column: str | None, | ||
size_column: str | None, | ||
) -> tuple[pd.DataFrame, str | None, str | None]: | ||
"""If multiple columns are set for y, melt the dataframe into long format.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could this comment be extended with an example? I am not sure what it means to melt a dataframe into long format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added more info to the comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing the refactoring 🙌 mainly left nits, but LGTM
Describe your changes
This PR refactors/restructures our backend logic that handles all vega-related charting:
st.vega_lite_chart
,st.altair_chart
,st.line_chart
,st.area_chart
,st.bar_chart
,st.scatter_chart
.built_in_chart_utils
vega_charts
and refactored to reuse more shared logic.add_rows
metadata by just relaying on the available metadata instead of checking for the delta type.Testing Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.