We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Altair support - Layer charts, `.resolve_scale` dont appear to work
# Summary

Altair appears to work just fine inside streamlit, but I have problems getting layer charts to work. Note - Concat (vert/horizontal) of altair charts works fine, but doing something like
```
(chart1 + chart2).resolve_scale(y='independent') 
```
results in everything going blank and no chart canvas displayed

# Steps to reproduce

What are the steps we should take to reproduce the bug:

1. Build 2 altair charts inside the same streamlit script, ideally with a shared x-axis like time/date (so it makes sense to crate a compound chart)
2. try to layer them using `(chart1 + chart2).resolve_scale(y='independent')`

## Expected behavior:

The layer chart should display with different y-axes
## Actual behavior:

Nothing displays - the chart fades as if to reload but everything goes blank

## Is this a regression?

this works elsewhere, e.g. in jupyterlab

# Debug info

- Streamlit version: 0.60.0
- Python version: Python 3.7.4
- Using Conda
- OS version: Mac OS X Catalina
- Browser version: Brave, Version 1.10.97 Chromium: 83.0.4103.116

# Additional information

If needed, add any other context about the problem here. For example, did this bug come from https://discuss.streamlit.io or another site? Link the original source here!


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `e2e_playwright/st_altair_chart.py`
Content:
```
1 # Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024)
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 import altair as alt
16 import numpy as np
17 import pandas as pd
18 
19 import streamlit as st
20 
21 np.random.seed(0)
22 
23 data = np.random.randn(200, 3)
24 df = pd.DataFrame(data, columns=["a", "b", "c"])
25 chart = alt.Chart(df).mark_circle().encode(x="a", y="b", size="c", color="c")
26 
27 st.write("Show default vega lite theme:")
28 st.altair_chart(chart, theme=None)
29 
30 st.write("Show streamlit theme:")
31 st.altair_chart(chart, theme="streamlit")
32 
33 st.write("Overwrite theme config:")
34 chart = (
35     alt.Chart(df, usermeta={"embedOptions": {"theme": None}})
36     .mark_circle()
37     .encode(x="a", y="b", size="c", color="c")
38 )
39 st.altair_chart(chart, theme="streamlit")
40 
41 data = pd.DataFrame(
42     {
43         "a": ["A", "B", "C", "D", "E", "F", "G", "H", "I"],
44         "b": [28, 55, 43, 91, 81, 53, 19, 87, 52],
45     }
46 )
47 
48 chart = alt.Chart(data).mark_bar().encode(x="a", y="b")
49 
50 st.write("Bar chart with overwritten theme props:")
51 st.altair_chart(chart.configure_mark(color="black"), theme="streamlit")
52 
53 # mark_arc was added in 4.2, but we have to support altair 4.0-4.1, so we
54 # have to skip this part of the test when testing min versions.
55 major, minor, patch = alt.__version__.split(".")
56 if not (major == "4" and minor < "2"):
57     source = pd.DataFrame(
58         {"category": [1, 2, 3, 4, 5, 6], "value": [4, 6, 10, 3, 7, 8]}
59     )
60 
61     chart = (
62         alt.Chart(source)
63         .mark_arc(innerRadius=50)
64         .encode(
65             theta=alt.Theta(field="value", type="quantitative"),
66             color=alt.Color(field="category", type="nominal"),
67         )
68     )
69 
70     st.write("Pie Chart with more than 4 Legend items")
71     st.altair_chart(chart, theme="streamlit")
72 
73 # taken from vega_datasets barley example
74 barley = alt.UrlData(
75     "https://cdn.jsdelivr.net/npm/vega-datasets@v2.7.0/data/barley.json"
76 )
77 
78 barley_chart = (
79     alt.Chart(barley)
80     .mark_bar()
81     .encode(x="year:O", y="sum(yield):Q", color="year:N", column="site:N")
82 )
83 
84 st.write("Grouped Bar Chart with default theme:")
85 st.altair_chart(barley_chart, theme=None)
86 
87 st.write("Grouped Bar Chart with streamlit theme:")
88 st.altair_chart(barley_chart, theme="streamlit")
89 
90 st.write("Chart with use_container_width used")
91 st.altair_chart(barley_chart, theme=None, use_container_width=True)
92 
93 st.write("Layered chart")
94 # Taken from vega_datasets
95 stocks = alt.UrlData(
96     "https://cdn.jsdelivr.net/npm/vega-datasets@v1.29.0/data/stocks.csv"
97 )
98 
99 base = (
100     alt.Chart(stocks)
101     .encode(x="date:T", y="price:Q", color="symbol:N")
102     .transform_filter(alt.datum.symbol == "GOOG")
103 )
104 
105 new_base_chart = base.mark_line() + base.mark_point()
106 st.altair_chart(new_base_chart)
107 
108 x = np.linspace(10, 100, 10)
109 y1 = 5 * x
110 y2 = 1 / x
111 
112 df1 = pd.DataFrame.from_dict({"x": x, "y1": y1, "y2": y2})
113 
114 c1 = alt.Chart(df1).mark_line().encode(alt.X("x"), alt.Y("y1"))
115 
116 c2 = alt.Chart(df1).mark_line().encode(alt.X("x"), alt.Y("y2"))
117 
118 st.altair_chart(c1 & c2, use_container_width=True)
119
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/e2e_playwright/st_altair_chart.py b/e2e_playwright/st_altair_chart.py
--- a/e2e_playwright/st_altair_chart.py
+++ b/e2e_playwright/st_altair_chart.py
@@ -116,3 +116,20 @@
 c2 = alt.Chart(df1).mark_line().encode(alt.X("x"), alt.Y("y2"))
 
 st.altair_chart(c1 & c2, use_container_width=True)
+
+from altair.expr import datum
+
+results = [
+    [2016, 11525, 3],
+    [2017, 11517, 2],
+    [2018, 11521, 2],
+    [2019, 11519, 4],
+]
+
+dataframe = pd.DataFrame(results, columns=["Job Number", "Test Count", "Test Failures"])
+
+base = alt.Chart(dataframe).encode(alt.X("Job Number:O"))
+chart_test_count = base.mark_line().encode(alt.Y("Test Count:N"))
+chart_test_failures = base.mark_line().encode(alt.Y("Test Failures:N"))
+
+st.altair_chart((chart_test_count + chart_test_failures).resolve_scale(y="independent"))

{"golden_diff": "diff --git a/e2e_playwright/st_altair_chart.py b/e2e_playwright/st_altair_chart.py\n--- a/e2e_playwright/st_altair_chart.py\n+++ b/e2e_playwright/st_altair_chart.py\n@@ -116,3 +116,20 @@\n c2 = alt.Chart(df1).mark_line().encode(alt.X(\"x\"), alt.Y(\"y2\"))\n \n st.altair_chart(c1 & c2, use_container_width=True)\n+\n+from altair.expr import datum\n+\n+results = [\n+    [2016, 11525, 3],\n+    [2017, 11517, 2],\n+    [2018, 11521, 2],\n+    [2019, 11519, 4],\n+]\n+\n+dataframe = pd.DataFrame(results, columns=[\"Job Number\", \"Test Count\", \"Test Failures\"])\n+\n+base = alt.Chart(dataframe).encode(alt.X(\"Job Number:O\"))\n+chart_test_count = base.mark_line().encode(alt.Y(\"Test Count:N\"))\n+chart_test_failures = base.mark_line().encode(alt.Y(\"Test Failures:N\"))\n+\n+st.altair_chart((chart_test_count + chart_test_failures).resolve_scale(y=\"independent\"))\n", "issue": "Altair support - Layer charts, `.resolve_scale` dont appear to work\n# Summary\r\n\r\nAltair appears to work just fine inside streamlit, but I have problems getting layer charts to work. Note - Concat (vert/horizontal) of altair charts works fine, but doing something like\r\n```\r\n(chart1 + chart2).resolve_scale(y='independent') \r\n```\r\nresults in everything going blank and no chart canvas displayed\r\n\r\n# Steps to reproduce\r\n\r\nWhat are the steps we should take to reproduce the bug:\r\n\r\n1. Build 2 altair charts inside the same streamlit script, ideally with a shared x-axis like time/date (so it makes sense to crate a compound chart)\r\n2. try to layer them using `(chart1 + chart2).resolve_scale(y='independent')`\r\n\r\n## Expected behavior:\r\n\r\nThe layer chart should display with different y-axes\r\n## Actual behavior:\r\n\r\nNothing displays - the chart fades as if to reload but everything goes blank\r\n\r\n## Is this a regression?\r\n\r\nthis works elsewhere, e.g. in jupyterlab\r\n\r\n# Debug info\r\n\r\n- Streamlit version: 0.60.0\r\n- Python version: Python 3.7.4\r\n- Using Conda\r\n- OS version: Mac OS X Catalina\r\n- Browser version: Brave, Version 1.10.97 Chromium: 83.0.4103.116\r\n\r\n# Additional information\r\n\r\nIf needed, add any other context about the problem here. For example, did this bug come from https://discuss.streamlit.io or another site? Link the original source here!\r\n\n", "before_files": [{"content": "# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024)\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport altair as alt\nimport numpy as np\nimport pandas as pd\n\nimport streamlit as st\n\nnp.random.seed(0)\n\ndata = np.random.randn(200, 3)\ndf = pd.DataFrame(data, columns=[\"a\", \"b\", \"c\"])\nchart = alt.Chart(df).mark_circle().encode(x=\"a\", y=\"b\", size=\"c\", color=\"c\")\n\nst.write(\"Show default vega lite theme:\")\nst.altair_chart(chart, theme=None)\n\nst.write(\"Show streamlit theme:\")\nst.altair_chart(chart, theme=\"streamlit\")\n\nst.write(\"Overwrite theme config:\")\nchart = (\n    alt.Chart(df, usermeta={\"embedOptions\": {\"theme\": None}})\n    .mark_circle()\n    .encode(x=\"a\", y=\"b\", size=\"c\", color=\"c\")\n)\nst.altair_chart(chart, theme=\"streamlit\")\n\ndata = pd.DataFrame(\n    {\n        \"a\": [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\"],\n        \"b\": [28, 55, 43, 91, 81, 53, 19, 87, 52],\n    }\n)\n\nchart = alt.Chart(data).mark_bar().encode(x=\"a\", y=\"b\")\n\nst.write(\"Bar chart with overwritten theme props:\")\nst.altair_chart(chart.configure_mark(color=\"black\"), theme=\"streamlit\")\n\n# mark_arc was added in 4.2, but we have to support altair 4.0-4.1, so we\n# have to skip this part of the test when testing min versions.\nmajor, minor, patch = alt.__version__.split(\".\")\nif not (major == \"4\" and minor < \"2\"):\n    source = pd.DataFrame(\n        {\"category\": [1, 2, 3, 4, 5, 6], \"value\": [4, 6, 10, 3, 7, 8]}\n    )\n\n    chart = (\n        alt.Chart(source)\n        .mark_arc(innerRadius=50)\n        .encode(\n            theta=alt.Theta(field=\"value\", type=\"quantitative\"),\n            color=alt.Color(field=\"category\", type=\"nominal\"),\n        )\n    )\n\n    st.write(\"Pie Chart with more than 4 Legend items\")\n    st.altair_chart(chart, theme=\"streamlit\")\n\n# taken from vega_datasets barley example\nbarley = alt.UrlData(\n    \"https://cdn.jsdelivr.net/npm/vega-datasets@v2.7.0/data/barley.json\"\n)\n\nbarley_chart = (\n    alt.Chart(barley)\n    .mark_bar()\n    .encode(x=\"year:O\", y=\"sum(yield):Q\", color=\"year:N\", column=\"site:N\")\n)\n\nst.write(\"Grouped Bar Chart with default theme:\")\nst.altair_chart(barley_chart, theme=None)\n\nst.write(\"Grouped Bar Chart with streamlit theme:\")\nst.altair_chart(barley_chart, theme=\"streamlit\")\n\nst.write(\"Chart with use_container_width used\")\nst.altair_chart(barley_chart, theme=None, use_container_width=True)\n\nst.write(\"Layered chart\")\n# Taken from vega_datasets\nstocks = alt.UrlData(\n    \"https://cdn.jsdelivr.net/npm/vega-datasets@v1.29.0/data/stocks.csv\"\n)\n\nbase = (\n    alt.Chart(stocks)\n    .encode(x=\"date:T\", y=\"price:Q\", color=\"symbol:N\")\n    .transform_filter(alt.datum.symbol == \"GOOG\")\n)\n\nnew_base_chart = base.mark_line() + base.mark_point()\nst.altair_chart(new_base_chart)\n\nx = np.linspace(10, 100, 10)\ny1 = 5 * x\ny2 = 1 / x\n\ndf1 = pd.DataFrame.from_dict({\"x\": x, \"y1\": y1, \"y2\": y2})\n\nc1 = alt.Chart(df1).mark_line().encode(alt.X(\"x\"), alt.Y(\"y1\"))\n\nc2 = alt.Chart(df1).mark_line().encode(alt.X(\"x\"), alt.Y(\"y2\"))\n\nst.altair_chart(c1 & c2, use_container_width=True)\n", "path": "e2e_playwright/st_altair_chart.py"}], "after_files": [{"content": "# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024)\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport altair as alt\nimport numpy as np\nimport pandas as pd\n\nimport streamlit as st\n\nnp.random.seed(0)\n\ndata = np.random.randn(200, 3)\ndf = pd.DataFrame(data, columns=[\"a\", \"b\", \"c\"])\nchart = alt.Chart(df).mark_circle().encode(x=\"a\", y=\"b\", size=\"c\", color=\"c\")\n\nst.write(\"Show default vega lite theme:\")\nst.altair_chart(chart, theme=None)\n\nst.write(\"Show streamlit theme:\")\nst.altair_chart(chart, theme=\"streamlit\")\n\nst.write(\"Overwrite theme config:\")\nchart = (\n    alt.Chart(df, usermeta={\"embedOptions\": {\"theme\": None}})\n    .mark_circle()\n    .encode(x=\"a\", y=\"b\", size=\"c\", color=\"c\")\n)\nst.altair_chart(chart, theme=\"streamlit\")\n\ndata = pd.DataFrame(\n    {\n        \"a\": [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\"],\n        \"b\": [28, 55, 43, 91, 81, 53, 19, 87, 52],\n    }\n)\n\nchart = alt.Chart(data).mark_bar().encode(x=\"a\", y=\"b\")\n\nst.write(\"Bar chart with overwritten theme props:\")\nst.altair_chart(chart.configure_mark(color=\"black\"), theme=\"streamlit\")\n\n# mark_arc was added in 4.2, but we have to support altair 4.0-4.1, so we\n# have to skip this part of the test when testing min versions.\nmajor, minor, patch = alt.__version__.split(\".\")\nif not (major == \"4\" and minor < \"2\"):\n    source = pd.DataFrame(\n        {\"category\": [1, 2, 3, 4, 5, 6], \"value\": [4, 6, 10, 3, 7, 8]}\n    )\n\n    chart = (\n        alt.Chart(source)\n        .mark_arc(innerRadius=50)\n        .encode(\n            theta=alt.Theta(field=\"value\", type=\"quantitative\"),\n            color=alt.Color(field=\"category\", type=\"nominal\"),\n        )\n    )\n\n    st.write(\"Pie Chart with more than 4 Legend items\")\n    st.altair_chart(chart, theme=\"streamlit\")\n\n# taken from vega_datasets barley example\nbarley = alt.UrlData(\n    \"https://cdn.jsdelivr.net/npm/vega-datasets@v2.7.0/data/barley.json\"\n)\n\nbarley_chart = (\n    alt.Chart(barley)\n    .mark_bar()\n    .encode(x=\"year:O\", y=\"sum(yield):Q\", color=\"year:N\", column=\"site:N\")\n)\n\nst.write(\"Grouped Bar Chart with default theme:\")\nst.altair_chart(barley_chart, theme=None)\n\nst.write(\"Grouped Bar Chart with streamlit theme:\")\nst.altair_chart(barley_chart, theme=\"streamlit\")\n\nst.write(\"Chart with use_container_width used\")\nst.altair_chart(barley_chart, theme=None, use_container_width=True)\n\nst.write(\"Layered chart\")\n# Taken from vega_datasets\nstocks = alt.UrlData(\n    \"https://cdn.jsdelivr.net/npm/vega-datasets@v1.29.0/data/stocks.csv\"\n)\n\nbase = (\n    alt.Chart(stocks)\n    .encode(x=\"date:T\", y=\"price:Q\", color=\"symbol:N\")\n    .transform_filter(alt.datum.symbol == \"GOOG\")\n)\n\nnew_base_chart = base.mark_line() + base.mark_point()\nst.altair_chart(new_base_chart)\n\nx = np.linspace(10, 100, 10)\ny1 = 5 * x\ny2 = 1 / x\n\ndf1 = pd.DataFrame.from_dict({\"x\": x, \"y1\": y1, \"y2\": y2})\n\nc1 = alt.Chart(df1).mark_line().encode(alt.X(\"x\"), alt.Y(\"y1\"))\n\nc2 = alt.Chart(df1).mark_line().encode(alt.X(\"x\"), alt.Y(\"y2\"))\n\nst.altair_chart(c1 & c2, use_container_width=True)\n\nfrom altair.expr import datum\n\nresults = [\n    [2016, 11525, 3],\n    [2017, 11517, 2],\n    [2018, 11521, 2],\n    [2019, 11519, 4],\n]\n\ndataframe = pd.DataFrame(results, columns=[\"Job Number\", \"Test Count\", \"Test Failures\"])\n\nbase = alt.Chart(dataframe).encode(alt.X(\"Job Number:O\"))\nchart_test_count = base.mark_line().encode(alt.Y(\"Test Count:N\"))\nchart_test_failures = base.mark_line().encode(alt.Y(\"Test Failures:N\"))\n\nst.altair_chart((chart_test_count + chart_test_failures).resolve_scale(y=\"independent\"))\n", "path": "e2e_playwright/st_altair_chart.py"}]}