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

Area charts broken in >=5.14.1 #9337

Open
1 task done
lukasmasuch opened this issue May 3, 2024 · 5 comments
Open
1 task done

Area charts broken in >=5.14.1 #9337

lukasmasuch opened this issue May 3, 2024 · 5 comments
Assignees
Labels

Comments

@lukasmasuch
Copy link

lukasmasuch commented May 3, 2024

Bug Description

We would like to update the vega-lite dependency in Streamlit to the latest version. However, the area charts seem to be broken in vega-lite >=5.14.1. This might be related to this PR: #9018

in 5.14.0 (expected):

Screenshot 2024-05-03 at 20 00 15

in 5.14.1 (broken):

Screenshot 2024-05-03 at 19 57 59

Here is the current spec based on st.area_chart in Streamlit. I will try to provide a reproducible example within the next couple of days:

{
  "data": {"name": "6275643184"},
  "mark": {"type": "area"},
  "encoding": {
    "color": {
      "field": "color--p5bJXXpQgvPz6yvQMFiy",
      "legend": {"titlePadding": 5, "offset": 5, "orient": "bottom"},
      "title": " ",
      "type": "nominal"
    },
    "opacity": {"value": 0.7},
    "tooltip": [
      {
        "field": "index--p5bJXXpQgvPz6yvQMFiy",
        "title": "index",
        "type": "quantitative"
      },
      {
        "field": "value--p5bJXXpQgvPz6yvQMFiy",
        "title": "value",
        "type": "quantitative"
      },
      {
        "field": "color--p5bJXXpQgvPz6yvQMFiy",
        "title": "color",
        "type": "nominal"
      }
    ],
    "x": {
      "axis": {"grid": false, "tickMinStep": 1},
      "field": "index--p5bJXXpQgvPz6yvQMFiy",
      "scale": {},
      "title": "",
      "type": "quantitative"
    },
    "y": {
      "axis": {"grid": true},
      "field": "value--p5bJXXpQgvPz6yvQMFiy",
      "scale": {},
      "title": "",
      "type": "quantitative"
    }
  },
  "height": 0,
  "params": [
    {
      "name": "param_6",
      "select": {"type": "interval", "encodings": ["x", "y"]},
      "bind": "scales"
    }
  ],
  "width": 704,
  "$schema": "https://vega.github.io/schema/vega-lite/v5.17.0.json",
  "autosize": {"type": "fit", "contains": "padding"},
}

Checklist

  • I checked for duplicate issues.
lukasmasuch added a commit to streamlit/streamlit that referenced this issue May 4, 2024
## Describe your changes

This PR updates all vega-related frontend dependencies and applies some
refactoring by moving all the arrow-data handling logic into a dedicated
`arrowUtils` file.

This is mainly done because `vega-embed` cannot be tested with jest
because of an issue with jsdom:
jsdom/jsdom#3363

Unfortunately, we cannot update the `vega-lite` dependency to the latest
version since it breaks our stacked area charts in version >=5.14.1.
Related issue: vega/vega-lite#9337

---

**Contribution License Agreement**

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

domoritz commented May 4, 2024

@yhoonkim @kanitw can you look at this?

@lukasmasuch
Copy link
Author

bump: just tried to update Streamlit to use 5.21 ... but the issue still exists :(

lukasmasuch added a commit to streamlit/streamlit that referenced this issue Sep 11, 2024
## Describe your changes

Updates the vega frontend dependencies to correctly support new
features, e.g. #9438


https://github.com/user-attachments/assets/90af948f-45f0-4c5b-ab40-c5f990ee3df6

Unfortunately, we cannot update the vega-lite dependency to the latest
version since it breaks our stacked area charts in version >=5.14.1.
Related issue: vega/vega-lite#9337

## GitHub Issue Link (if applicable)

- Closes #9438

## Testing Plan

- Since this is just a new Vega feature and not a Streamlit feature, we
don't really need testing for this on our side (same with the majority
of other vega features). There isn't anything on the Streamlit side that
influences this feature support other than not updated dependencies.


---

**Contribution License Agreement**

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

Could you bisect what change causes this issue?

@lukasmasuch
Copy link
Author

I looked more into it, and it seems that the default stack behavior for area charts was changed in 5.14.1. To fix this on our side, we just need to provide stack=False on the axis. With this workaround, we can update to the latest vega-lite.

To close this issue, I'm not sure if the behavior < 5.14.1 was broken or if the current behavior is broken. Other related issues:

#9170
vega/altair#3558

@domoritz
Copy link
Member

domoritz commented Sep 12, 2024

Stacking should work if the data for the line and area are aligned. If not, it's hard to say what the correct behavior is anyway so that's probably what's going on here. Also, you can't stack negative values. Your original example isn't actually stacked so I don't think the title of this issue is correct. Without an example it's hard to say whether there is a bug but I think this is working as expected and you can disable stacking for you use case. Glad to hear it's what you need to update.

@yhoonkim and @kanitw do you agree? Asking since you worked on #9018.

@lukasmasuch lukasmasuch changed the title Stacked area charts broken in >=5.14.1 Area charts broken in >=5.14.1 Sep 12, 2024
lukasmasuch added a commit to streamlit/streamlit that referenced this issue Sep 12, 2024
## Describe your changes

The default stack behavior for area charts was changed in vega-lite
5.14.1 (more context in vega/vega-lite#9337).
To update to the latest frontend dependency, we also need to change the
default stack value for our built-in charts.

## Testing Plan

- The existing tests should cover everything.

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.
benjamin-awd pushed a commit to benjamin-awd/streamlit that referenced this issue Sep 29, 2024
## Describe your changes

This PR updates all vega-related frontend dependencies and applies some
refactoring by moving all the arrow-data handling logic into a dedicated
`arrowUtils` file.

This is mainly done because `vega-embed` cannot be tested with jest
because of an issue with jsdom:
jsdom/jsdom#3363

Unfortunately, we cannot update the `vega-lite` dependency to the latest
version since it breaks our stacked area charts in version >=5.14.1.
Related issue: vega/vega-lite#9337

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.
edegp pushed a commit to edegp/streamlit that referenced this issue Jan 19, 2025
…9443)

## Describe your changes

Updates the vega frontend dependencies to correctly support new
features, e.g. streamlit#9438


https://github.com/user-attachments/assets/90af948f-45f0-4c5b-ab40-c5f990ee3df6

Unfortunately, we cannot update the vega-lite dependency to the latest
version since it breaks our stacked area charts in version >=5.14.1.
Related issue: vega/vega-lite#9337

## GitHub Issue Link (if applicable)

- Closes streamlit#9438

## Testing Plan

- Since this is just a new Vega feature and not a Streamlit feature, we
don't really need testing for this on our side (same with the majority
of other vega features). There isn't anything on the Streamlit side that
influences this feature support other than not updated dependencies.


---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.
edegp pushed a commit to edegp/streamlit that referenced this issue Jan 19, 2025
## Describe your changes

The default stack behavior for area charts was changed in vega-lite
5.14.1 (more context in vega/vega-lite#9337).
To update to the latest frontend dependency, we also need to change the
default stack value for our built-in charts.

## Testing Plan

- The existing tests should cover everything.

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants