Skip to content

Conversation

sfc-gh-tteixeira
Copy link
Contributor

Describe your changes

Introduce a library for handling/converting colors in Python. This library isn't used yet, but it will be in a couple of follow-up PRs. The reason I'm sending this PR this way is to make it easier to review all the code!

This is part of the work to:

  1. Add a color argument to our native charts
  2. Add latitude, longitude, color, and size to to st.map
  3. Add st.scatter_chart

GitHub Issue Link (if applicable)

None

Testing Plan

  • Explanation of why no additional tests are needed
    n/a

  • Unit Tests (JS and/or Python)

  • E2E Tests
    n/a

  • Any manual testing needed?
    No. This isn't library connected to anything right now


Contribution License Agreement

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

@sfc-gh-tteixeira sfc-gh-tteixeira marked this pull request as ready for review June 22, 2023 23:05
@willhuang1997
Copy link
Contributor

willhuang1997 commented Jun 23, 2023

I see some failure on type checking for python but I personally don't understand why it's failing when the length is 4 and it should have a 4th element. However, I added the labels for the pull request so that should fulfill some of the github actions checks!

I asked chat-gpt and it gave me a terrible response 😆

if len(color) == 3:
    r = rgb_formatter(color[0], color)
    g = rgb_formatter(color[1], color)
    b = rgb_formatter(color[2], color)
    return r, g, b

elif len(color) == 4:
    r = rgb_formatter(color[0], color)
    g = rgb_formatter(color[1], color)
    b = rgb_formatter(color[2], color)
    if len(color) == 4:
        alpha = alpha_formatter(color[3], color)
        return r, g, b, alpha
    else:
        # Handle the case when len(color) is not 4
        # This could be an error condition or a default value for alpha
        # Return or assign an appropriate value based on your requirements
        return r, g, b, None  # Example: returning None as a default value

@sfc-gh-tteixeira
Copy link
Contributor Author

I see some failure on type checking for python (...)

Fixed by casting to a 4-tuple.

@sfc-gh-tteixeira sfc-gh-tteixeira merged commit bf20ec6 into streamlit:develop Jun 24, 2023
@sfc-gh-tteixeira sfc-gh-tteixeira deleted the color_util branch June 24, 2023 00:05
tconkling added a commit to tconkling/streamlit that referenced this pull request Jun 26, 2023
* develop:
  Add color_util.py, which will be used by native charts in next few PRs. (streamlit#6826)
@sfc-gh-tteixeira sfc-gh-tteixeira mentioned this pull request Jul 22, 2023
@sfc-gh-tteixeira sfc-gh-tteixeira mentioned this pull request Aug 12, 2023
eric-skydio pushed a commit to eric-skydio/streamlit that referenced this pull request Dec 20, 2023
…s. (streamlit#6826)

* Add color_util.py, which will be used by native charts in next few PRs.

* Trying to fix typing

* Fix color_util typing

* Output tuples

* Small code adjustments, plus typing improvements

* Cleaning up some code

* Resolve comments.

* Better comments.
zyxue pushed a commit to zyxue/streamlit that referenced this pull request Mar 22, 2024
…s. (streamlit#6826)

* Add color_util.py, which will be used by native charts in next few PRs.

* Trying to fix typing

* Fix color_util typing

* Output tuples

* Small code adjustments, plus typing improvements

* Cleaning up some code

* Resolve comments.

* Better comments.
zyxue pushed a commit to zyxue/streamlit that referenced this pull request Apr 16, 2024
…s. (streamlit#6826)

* Add color_util.py, which will be used by native charts in next few PRs.

* Trying to fix typing

* Fix color_util typing

* Output tuples

* Small code adjustments, plus typing improvements

* Cleaning up some code

* Resolve comments.

* Better comments.
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.

2 participants