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

vega_lite_chart displays wrong data due to premature caching optimization on the front end #6689

Open
4 of 5 tasks
vskarine opened this issue May 15, 2023 · 3 comments · May be fixed by #8499
Open
4 of 5 tasks

vega_lite_chart displays wrong data due to premature caching optimization on the front end #6689

vskarine opened this issue May 15, 2023 · 3 comments · May be fixed by #8499
Assignees
Labels
feature:st.vega_lite_chart priority:P2 status:confirmed Bug has been confirmed by the Streamlit team type:bug Something isn't working

Comments

@vskarine
Copy link

vskarine commented May 15, 2023

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

  • create vega_lite_chart and populate it with some data
  • keep first and last values in the array the same as before BUT add several data points to the data but also change some data in the middle
  • Following code only checks first and last items in the array and determines that whole array is the same as before therefore no need to re-render middle parts which is absolutely wrong:
    // (this is a very light check, and not guaranteed to be right!)

Reproducible Code Example

Open in Streamlit Cloud

import pandas as pd
import streamlit as st

data1 = {
  "VALUE": [420, 380, 390],
  "DATE": [50, 60, 70]
}
data = pd.DataFrame(data1)

data2 = {
  "VALUE": [420, 200, 390, 600],
  "DATE": [50, 60, 70, 80]
}


if st.button(label="change"):
    data = pd.DataFrame(data2)
st.vega_lite_chart(
    data=pd.DataFrame(data),
    spec={
        "autosize": {
            "type": "fit",
            "contains": "padding",
            "resize": True,
        },
        "title": "test",
        "layer": [
            {
                "layer": [
                    {
                        "mark": "line",
                    },
                ],
                "encoding": {
                    "x": {
                        "field": "DATE",
                        "title": "",
                        "type": "quantitative",
                    },
                    "y": {
                        "field": "VALUE",
                        "title": "",
                        "type": "quantitative",
                    },
                },
            },
        ],
    },
    use_container_width=True,
    theme="streamlit",
)


st.vega_lite_chart(
    data=pd.DataFrame(data2),
    spec={
        "autosize": {
            "type": "fit",
            "contains": "padding",
            "resize": True,
        },
        "title": "test",
        "layer": [
            {
                "layer": [
                    {
                        "mark": "line",
                    },
                ],
                "encoding": {
                    "x": {
                        "field": "DATE",
                        "title": "",
                        "type": "quantitative",
                    },
                    "y": {
                        "field": "VALUE",
                        "title": "",
                        "type": "quantitative",
                    },
                },
            },
        ],
    },
    use_container_width=True,
    theme="streamlit",
)

Steps To Reproduce

run the code and click "change" button

Expected Behavior

charts become the same

Current Behavior

charts are different

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

it's been there for past 2 years or so

Additional Information

No response

Are you willing to submit a PR?

  • Yes, I am willing to submit a PR!
@vskarine vskarine added status:needs-triage Has not been triaged by the Streamlit team type:bug Something isn't working labels May 15, 2023
@willhuang1997 willhuang1997 added status:confirmed Bug has been confirmed by the Streamlit team priority:P1 feature:st.vega_lite_chart and removed type:bug Something isn't working status:needs-triage Has not been triaged by the Streamlit team labels May 16, 2023
@carolinedlu
Copy link
Collaborator

Hey @vskarine, thanks for sharing this issue! Our team was able to reproduce the behavior and we're planning a fix.

@kmcgrady kmcgrady added the type:bug Something isn't working label Aug 29, 2023
@github-actions
Copy link

If this issue affects you, please react with a 👍 (thumbs up emoji) to the initial post.

Your feedback helps us prioritize which bugs to investigate and address first.

Visits

@kmcgrady
Copy link
Collaborator

kmcgrady commented Nov 7, 2023

@willhuang1997 I heard from @sfc-gh-jcarroll that you investigated this bug. Any chance you can shed light to the problem here, and how we can solve it?

@kmcgrady kmcgrady self-assigned this Apr 14, 2024
@kmcgrady kmcgrady linked a pull request Apr 14, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:st.vega_lite_chart priority:P2 status:confirmed Bug has been confirmed by the Streamlit team type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants