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

Scatter chart #7164

Merged
merged 67 commits into from Sep 1, 2023
Merged

Conversation

sfc-gh-tteixeira
Copy link
Contributor

Describe your changes

Add support for st.scatter_chart!

This is PR 4 in the work to:

  • Add latitude, longitude, color, and size to to st.map. This was PR 2.
  • Add a color argument to our native charts. This was PR 3
  • Add st.scatter_chart. 👈👈👈 THAT'S THIS PR!

(PR 1 was a no-op that added the color_util.py library, which is used in this and the next PRs)

GitHub Issue Link (if applicable)

Testing Plan

  • N/A - Explanation of why no additional tests are needed

  • ✅ Unit Tests (JS and/or Python)

  • ✅ E2E Tests

  • Any manual testing needed?

    Yes. I'll request this from the QA team soon.


Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

# through trial-and-error I found this value to be a good enough middle ground.
# See e2e/scripts/st_arrow_scatter_chart.py for some alignment tests.
COLOR_LEGEND_SETTINGS = dict(titlePadding=5, offset=5, orient="bottom")
SIZE_LEGEND_SETTINGS = dict(titlePadding=0.5, offset=5, orient="bottom")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think same here.

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 moved all I could to CustomTheme.tsx, but I need to leave the titlePadding here in Python because there's no way to set a different value for one encoding (i.e. color) vs another encoding (size).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I just realized that by moving this we broke some existing behavior.

When you create an Altair/Vega chart by hand, we used to (1) apply Streamlit colors, but (2) NOT move the legend to the bottom. With this change, we now DO move the legend to the bottom.

I need to double-check whether #2 was the desired behavior or just a bug.

Copy link
Collaborator

@willhuang1997 willhuang1997 left a comment

Choose a reason for hiding this comment

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

I don't think there's anything glaring about this PR so I'm going to give approval. However, please fix all of the comments please :)

@sfc-gh-tteixeira
Copy link
Contributor Author

QA request filed!

@mayagbarnes
Copy link
Collaborator

FWIW re: Python test failures:
test_arrow_chart_with_explicit_x_plus_y_and_color_sequence checks here for the legend specification set with (now removed) COLOR_LEGEND_SETTINGS in _get_color_encoding.

@kasim-inan kasim-inan added the QA-Done QA is Complete label Sep 1, 2023
@sfc-gh-tteixeira sfc-gh-tteixeira merged commit bdd1d9b into streamlit:develop Sep 1, 2023
52 checks passed
@sfc-gh-tteixeira sfc-gh-tteixeira deleted the scatter_chart branch September 1, 2023 21:18
eric-skydio pushed a commit to eric-skydio/streamlit that referenced this pull request Dec 20, 2023
* Add color support to charts, and refactor things a bit.

* Fix tests and types.

* Fix types in type_util

* Removin unnecessary DF cloning, and add test to ensure we're not mutating the orig DF.

* Fix tests in latest Pandas and Arrow.

* Revert st_arrow_add_rows test to avoid too many changes in this PR. Will land in another PR.

* Remove snaps that should be regenerated.

* Don't show labels when no x or y specified (to match existing behavior).

* Update snapshots (need to regenerate)

* Fix bug where x axis was sometimes quantitative rather than temporal.

* Implement st.scatter_chart

* Fix x enc when no x_column.

* Add more scatter tests

* Fix tests.

* Revert to melting data by hand since Snowflake doesn't include Altair 4.2

* Improve error messages.

* Fix MyPy types

* Update snapshots

* Fix empty check

* Revert setup.py

* Remove dead code.

* simple rename

* Remove more dead code

* Address comments.

* Address comments.

* Updating screenshot

* Fix snapshots

* Fix stupid copy/paste bug >_<

* Fix stupid copy/paste bug >_<

* Fix merge issues

* Add snapshots

* Small cleanup. Always use str() around dataset ids. Should be a no-op since JSON stringifies keys anyways, but this is cleaner.

* Fix doc bug.

* REALLY fix the doc bug

* Improve docstrings

* Address comments. Move legend settings to CustomTheme.tsx

* Rename test images.

* Address comments. Fixed test.

* Undo move of legend config to CustomTheme.tsx as it broke existing behavior.

* Fix tests

* Fix legend test.
zyxue pushed a commit to zyxue/streamlit that referenced this pull request Mar 22, 2024
* Add color support to charts, and refactor things a bit.

* Fix tests and types.

* Fix types in type_util

* Removin unnecessary DF cloning, and add test to ensure we're not mutating the orig DF.

* Fix tests in latest Pandas and Arrow.

* Revert st_arrow_add_rows test to avoid too many changes in this PR. Will land in another PR.

* Remove snaps that should be regenerated.

* Don't show labels when no x or y specified (to match existing behavior).

* Update snapshots (need to regenerate)

* Fix bug where x axis was sometimes quantitative rather than temporal.

* Implement st.scatter_chart

* Fix x enc when no x_column.

* Add more scatter tests

* Fix tests.

* Revert to melting data by hand since Snowflake doesn't include Altair 4.2

* Improve error messages.

* Fix MyPy types

* Update snapshots

* Fix empty check

* Revert setup.py

* Remove dead code.

* simple rename

* Remove more dead code

* Address comments.

* Address comments.

* Updating screenshot

* Fix snapshots

* Fix stupid copy/paste bug >_<

* Fix stupid copy/paste bug >_<

* Fix merge issues

* Add snapshots

* Small cleanup. Always use str() around dataset ids. Should be a no-op since JSON stringifies keys anyways, but this is cleaner.

* Fix doc bug.

* REALLY fix the doc bug

* Improve docstrings

* Address comments. Move legend settings to CustomTheme.tsx

* Rename test images.

* Address comments. Fixed test.

* Undo move of legend config to CustomTheme.tsx as it broke existing behavior.

* Fix tests

* Fix legend test.
zyxue pushed a commit to zyxue/streamlit that referenced this pull request Apr 16, 2024
* Add color support to charts, and refactor things a bit.

* Fix tests and types.

* Fix types in type_util

* Removin unnecessary DF cloning, and add test to ensure we're not mutating the orig DF.

* Fix tests in latest Pandas and Arrow.

* Revert st_arrow_add_rows test to avoid too many changes in this PR. Will land in another PR.

* Remove snaps that should be regenerated.

* Don't show labels when no x or y specified (to match existing behavior).

* Update snapshots (need to regenerate)

* Fix bug where x axis was sometimes quantitative rather than temporal.

* Implement st.scatter_chart

* Fix x enc when no x_column.

* Add more scatter tests

* Fix tests.

* Revert to melting data by hand since Snowflake doesn't include Altair 4.2

* Improve error messages.

* Fix MyPy types

* Update snapshots

* Fix empty check

* Revert setup.py

* Remove dead code.

* simple rename

* Remove more dead code

* Address comments.

* Address comments.

* Updating screenshot

* Fix snapshots

* Fix stupid copy/paste bug >_<

* Fix stupid copy/paste bug >_<

* Fix merge issues

* Add snapshots

* Small cleanup. Always use str() around dataset ids. Should be a no-op since JSON stringifies keys anyways, but this is cleaner.

* Fix doc bug.

* REALLY fix the doc bug

* Improve docstrings

* Address comments. Move legend settings to CustomTheme.tsx

* Rename test images.

* Address comments. Fixed test.

* Undo move of legend config to CustomTheme.tsx as it broke existing behavior.

* Fix tests

* Fix legend test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants