From 7093ca63d2851498289199129611ecf1b6cca32a Mon Sep 17 00:00:00 2001 From: Stefan Binder Date: Fri, 30 Dec 2022 19:34:43 +0000 Subject: [PATCH 1/4] Change default chart width to 300 --- altair/vegalite/v3/tests/test_api.py | 4 ++-- altair/vegalite/v3/tests/test_theme.py | 2 +- altair/vegalite/v3/theme.py | 6 +++--- altair/vegalite/v4/tests/test_api.py | 4 ++-- altair/vegalite/v4/tests/test_theme.py | 2 +- altair/vegalite/v4/theme.py | 6 +++--- altair/vegalite/v5/tests/test_api.py | 4 ++-- altair/vegalite/v5/tests/test_theme.py | 2 +- altair/vegalite/v5/theme.py | 6 +++--- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/altair/vegalite/v3/tests/test_api.py b/altair/vegalite/v3/tests/test_api.py index 489d8cf67..3b156612b 100644 --- a/altair/vegalite/v3/tests/test_api.py +++ b/altair/vegalite/v3/tests/test_api.py @@ -630,14 +630,14 @@ def test_themes(): alt.themes.enable("default") assert chart.to_dict()["config"] == { "mark": {"tooltip": None}, - "view": {"width": 400, "height": 300}, + "view": {"width": 300, "height": 300}, } alt.themes.enable("opaque") assert chart.to_dict()["config"] == { "background": "white", "mark": {"tooltip": None}, - "view": {"width": 400, "height": 300}, + "view": {"width": 300, "height": 300}, } alt.themes.enable("none") diff --git a/altair/vegalite/v3/tests/test_theme.py b/altair/vegalite/v3/tests/test_theme.py index 430c21935..1bed75838 100644 --- a/altair/vegalite/v3/tests/test_theme.py +++ b/altair/vegalite/v3/tests/test_theme.py @@ -15,6 +15,6 @@ def test_vega_themes(chart): dct = chart.to_dict() assert dct["usermeta"] == {"embedOptions": {"theme": theme}} assert dct["config"] == { - "view": {"width": 400, "height": 300}, + "view": {"width": 300, "height": 300}, "mark": {"tooltip": None}, } diff --git a/altair/vegalite/v3/theme.py b/altair/vegalite/v3/theme.py index 91d37649b..c2ed2a58f 100644 --- a/altair/vegalite/v3/theme.py +++ b/altair/vegalite/v3/theme.py @@ -15,7 +15,7 @@ def __call__(self): return { "usermeta": {"embedOptions": {"theme": self.theme}}, "config": { - "view": {"width": 400, "height": 300}, + "view": {"width": 300, "height": 300}, "mark": {"tooltip": None}, }, } @@ -33,7 +33,7 @@ def __repr__(self): themes.register( "default", lambda: { - "config": {"view": {"width": 400, "height": 300}, "mark": {"tooltip": None}} + "config": {"view": {"width": 300, "height": 300}, "mark": {"tooltip": None}} }, ) themes.register( @@ -41,7 +41,7 @@ def __repr__(self): lambda: { "config": { "background": "white", - "view": {"width": 400, "height": 300}, + "view": {"width": 300, "height": 300}, "mark": {"tooltip": None}, } }, diff --git a/altair/vegalite/v4/tests/test_api.py b/altair/vegalite/v4/tests/test_api.py index 450553f3c..9f68c85ec 100644 --- a/altair/vegalite/v4/tests/test_api.py +++ b/altair/vegalite/v4/tests/test_api.py @@ -659,13 +659,13 @@ def test_themes(): with alt.themes.enable("default"): assert chart.to_dict()["config"] == { - "view": {"continuousWidth": 400, "continuousHeight": 300} + "view": {"continuousWidth": 300, "continuousHeight": 300} } with alt.themes.enable("opaque"): assert chart.to_dict()["config"] == { "background": "white", - "view": {"continuousWidth": 400, "continuousHeight": 300}, + "view": {"continuousWidth": 300, "continuousHeight": 300}, } with alt.themes.enable("none"): diff --git a/altair/vegalite/v4/tests/test_theme.py b/altair/vegalite/v4/tests/test_theme.py index d159d2fa7..48a1f61ae 100644 --- a/altair/vegalite/v4/tests/test_theme.py +++ b/altair/vegalite/v4/tests/test_theme.py @@ -15,5 +15,5 @@ def test_vega_themes(chart): dct = chart.to_dict() assert dct["usermeta"] == {"embedOptions": {"theme": theme}} assert dct["config"] == { - "view": {"continuousWidth": 400, "continuousHeight": 300} + "view": {"continuousWidth": 300, "continuousHeight": 300} } diff --git a/altair/vegalite/v4/theme.py b/altair/vegalite/v4/theme.py index b1db45778..7e6a73b51 100644 --- a/altair/vegalite/v4/theme.py +++ b/altair/vegalite/v4/theme.py @@ -22,7 +22,7 @@ def __init__(self, theme): def __call__(self): return { "usermeta": {"embedOptions": {"theme": self.theme}}, - "config": {"view": {"continuousWidth": 400, "continuousHeight": 300}}, + "config": {"view": {"continuousWidth": 300, "continuousHeight": 300}}, } def __repr__(self): @@ -37,14 +37,14 @@ def __repr__(self): themes.register( "default", - lambda: {"config": {"view": {"continuousWidth": 400, "continuousHeight": 300}}}, + lambda: {"config": {"view": {"continuousWidth": 300, "continuousHeight": 300}}}, ) themes.register( "opaque", lambda: { "config": { "background": "white", - "view": {"continuousWidth": 400, "continuousHeight": 300}, + "view": {"continuousWidth": 300, "continuousHeight": 300}, } }, ) diff --git a/altair/vegalite/v5/tests/test_api.py b/altair/vegalite/v5/tests/test_api.py index 00f1389bd..3ba2321fd 100644 --- a/altair/vegalite/v5/tests/test_api.py +++ b/altair/vegalite/v5/tests/test_api.py @@ -703,13 +703,13 @@ def test_themes(): with alt.themes.enable("default"): assert chart.to_dict()["config"] == { - "view": {"continuousWidth": 400, "continuousHeight": 300} + "view": {"continuousWidth": 300, "continuousHeight": 300} } with alt.themes.enable("opaque"): assert chart.to_dict()["config"] == { "background": "white", - "view": {"continuousWidth": 400, "continuousHeight": 300}, + "view": {"continuousWidth": 300, "continuousHeight": 300}, } with alt.themes.enable("none"): diff --git a/altair/vegalite/v5/tests/test_theme.py b/altair/vegalite/v5/tests/test_theme.py index eaa2d8898..0eab5546d 100644 --- a/altair/vegalite/v5/tests/test_theme.py +++ b/altair/vegalite/v5/tests/test_theme.py @@ -15,5 +15,5 @@ def test_vega_themes(chart): dct = chart.to_dict() assert dct["usermeta"] == {"embedOptions": {"theme": theme}} assert dct["config"] == { - "view": {"continuousWidth": 400, "continuousHeight": 300} + "view": {"continuousWidth": 300, "continuousHeight": 300} } diff --git a/altair/vegalite/v5/theme.py b/altair/vegalite/v5/theme.py index 1f88f9696..ba396cb31 100644 --- a/altair/vegalite/v5/theme.py +++ b/altair/vegalite/v5/theme.py @@ -22,7 +22,7 @@ def __init__(self, theme): def __call__(self): return { "usermeta": {"embedOptions": {"theme": self.theme}}, - "config": {"view": {"continuousWidth": 400, "continuousHeight": 300}}, + "config": {"view": {"continuousWidth": 300, "continuousHeight": 300}}, } def __repr__(self): @@ -37,14 +37,14 @@ def __repr__(self): themes.register( "default", - lambda: {"config": {"view": {"continuousWidth": 400, "continuousHeight": 300}}}, + lambda: {"config": {"view": {"continuousWidth": 300, "continuousHeight": 300}}}, ) themes.register( "opaque", lambda: { "config": { "background": "white", - "view": {"continuousWidth": 400, "continuousHeight": 300}, + "view": {"continuousWidth": 300, "continuousHeight": 300}, } }, ) From e8fb726b839832b6a597bb95d87b84e16595576c Mon Sep 17 00:00:00 2001 From: Stefan Binder Date: Fri, 30 Dec 2022 19:50:14 +0000 Subject: [PATCH 2/4] Update documentation --- doc/user_guide/customization.rst | 4 ++-- doc/user_guide/internals.rst | 4 ++-- doc/user_guide/large_datasets.rst | 4 ++-- doc/user_guide/saving_charts.rst | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/user_guide/customization.rst b/doc/user_guide/customization.rst index 0c2ac5d51..a01866031 100644 --- a/doc/user_guide/customization.rst +++ b/doc/user_guide/customization.rst @@ -582,7 +582,7 @@ For example, the default theme configures the default size of a single chart: >>> import altair as alt >>> default = alt.themes.get() >>> default() - {'config': {'view': {'continuousWidth': 400, 'continuousHeight': 300}}} + {'config': {'view': {'continuousWidth': 300, 'continuousHeight': 300}}} You can see that any chart you create will have this theme applied, and these configurations added to its specification: @@ -673,7 +673,7 @@ fill unless otherwise specified: 'config': { 'view': { 'height': 300, - 'width': 400, + 'width': 300, }, 'mark': { 'color': 'black', diff --git a/doc/user_guide/internals.rst b/doc/user_guide/internals.rst index 104a6d4f9..f63479ad0 100644 --- a/doc/user_guide/internals.rst +++ b/doc/user_guide/internals.rst @@ -38,7 +38,7 @@ from which we can output the JSON representation: color='Origin:N', ).configure_view( continuousHeight=300, - continuousWidth=400, + continuousWidth=300, ) print(chart.to_json(indent=2)) @@ -98,7 +98,7 @@ the above chart using these low-level object types directly: config=alt.Config( view=alt.ViewConfig( continuousHeight=300, - continuousWidth=400 + continuousWidth=300 ) ) ) diff --git a/doc/user_guide/large_datasets.rst b/doc/user_guide/large_datasets.rst index 4c9e63481..5b2e025a9 100644 --- a/doc/user_guide/large_datasets.rst +++ b/doc/user_guide/large_datasets.rst @@ -54,7 +54,7 @@ simple chart made from a dataframe with three rows of data: .. code-block:: none {'$schema': 'https://vega.github.io/schema/vega-lite/v2.4.1.json', - 'config': {'view': {'height': 300, 'width': 400}}, + 'config': {'view': {'height': 300, 'width': 300}}, 'data': {'values': [{'x': 1, 'y': 2}, {'x': 2, 'y': 1}, {'x': 3, 'y': 2}]}, 'encoding': {'x': {'field': 'x', 'type': 'quantitative'}, 'y': {'field': 'y', 'type': 'quantitative'}}, @@ -119,7 +119,7 @@ You can also persist the data to disk and then pass the path to Altair: .. code-block:: none {'$schema': 'https://vega.github.io/schema/vega-lite/v2.4.1.json', - 'config': {'view': {'height': 300, 'width': 400}}, + 'config': {'view': {'height': 300, 'width': 300}}, 'data': {'url': 'data.json'}, 'encoding': {'x': {'field': 'x', 'type': 'quantitative'}, 'y': {'field': 'y', 'type': 'quantitative'}}, diff --git a/doc/user_guide/saving_charts.rst b/doc/user_guide/saving_charts.rst index aa3ad09a4..74c208fde 100644 --- a/doc/user_guide/saving_charts.rst +++ b/doc/user_guide/saving_charts.rst @@ -41,7 +41,7 @@ The contents of the resulting file will look something like this: "config": { "view": { "continuousHeight": 300, - "continuousWidth": 400 + "continuousWidth": 300 } }, "data": { @@ -101,7 +101,7 @@ javascript-enabled web browser: "config": { "view": { "continuousHeight": 300, - "continuousWidth": 400 + "continuousWidth": 300 } }, "data": { From a4571b1992db3c7624328e9e2c0a33d8d6007d53 Mon Sep 17 00:00:00 2001 From: Stefan Binder Date: Fri, 30 Dec 2022 19:52:40 +0000 Subject: [PATCH 3/4] Update vega-lite v4 reference to v5 --- doc/user_guide/saving_charts.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/user_guide/saving_charts.rst b/doc/user_guide/saving_charts.rst index 74c208fde..ec0d5939b 100644 --- a/doc/user_guide/saving_charts.rst +++ b/doc/user_guide/saving_charts.rst @@ -90,7 +90,7 @@ javascript-enabled web browser: - + From fc9f52cd6bc878286b7f094bd92c92a49c71160b Mon Sep 17 00:00:00 2001 From: Stefan Binder Date: Wed, 4 Jan 2023 18:46:53 +0000 Subject: [PATCH 4/4] Revert changes made in commit 7093ca63d2851498289199129611ecf1b6cca32a to v3 and v4 files --- altair/vegalite/v3/theme.py | 6 +++--- altair/vegalite/v4/theme.py | 6 +++--- tests/vegalite/v3/tests/test_api.py | 4 ++-- tests/vegalite/v3/tests/test_theme.py | 2 +- tests/vegalite/v4/tests/test_api.py | 4 ++-- tests/vegalite/v4/tests/test_theme.py | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/altair/vegalite/v3/theme.py b/altair/vegalite/v3/theme.py index c2ed2a58f..91d37649b 100644 --- a/altair/vegalite/v3/theme.py +++ b/altair/vegalite/v3/theme.py @@ -15,7 +15,7 @@ def __call__(self): return { "usermeta": {"embedOptions": {"theme": self.theme}}, "config": { - "view": {"width": 300, "height": 300}, + "view": {"width": 400, "height": 300}, "mark": {"tooltip": None}, }, } @@ -33,7 +33,7 @@ def __repr__(self): themes.register( "default", lambda: { - "config": {"view": {"width": 300, "height": 300}, "mark": {"tooltip": None}} + "config": {"view": {"width": 400, "height": 300}, "mark": {"tooltip": None}} }, ) themes.register( @@ -41,7 +41,7 @@ def __repr__(self): lambda: { "config": { "background": "white", - "view": {"width": 300, "height": 300}, + "view": {"width": 400, "height": 300}, "mark": {"tooltip": None}, } }, diff --git a/altair/vegalite/v4/theme.py b/altair/vegalite/v4/theme.py index 7e6a73b51..b1db45778 100644 --- a/altair/vegalite/v4/theme.py +++ b/altair/vegalite/v4/theme.py @@ -22,7 +22,7 @@ def __init__(self, theme): def __call__(self): return { "usermeta": {"embedOptions": {"theme": self.theme}}, - "config": {"view": {"continuousWidth": 300, "continuousHeight": 300}}, + "config": {"view": {"continuousWidth": 400, "continuousHeight": 300}}, } def __repr__(self): @@ -37,14 +37,14 @@ def __repr__(self): themes.register( "default", - lambda: {"config": {"view": {"continuousWidth": 300, "continuousHeight": 300}}}, + lambda: {"config": {"view": {"continuousWidth": 400, "continuousHeight": 300}}}, ) themes.register( "opaque", lambda: { "config": { "background": "white", - "view": {"continuousWidth": 300, "continuousHeight": 300}, + "view": {"continuousWidth": 400, "continuousHeight": 300}, } }, ) diff --git a/tests/vegalite/v3/tests/test_api.py b/tests/vegalite/v3/tests/test_api.py index 0093febfd..b61632c50 100644 --- a/tests/vegalite/v3/tests/test_api.py +++ b/tests/vegalite/v3/tests/test_api.py @@ -631,14 +631,14 @@ def test_themes(): alt.themes.enable("default") assert chart.to_dict()["config"] == { "mark": {"tooltip": None}, - "view": {"width": 300, "height": 300}, + "view": {"width": 400, "height": 300}, } alt.themes.enable("opaque") assert chart.to_dict()["config"] == { "background": "white", "mark": {"tooltip": None}, - "view": {"width": 300, "height": 300}, + "view": {"width": 400, "height": 300}, } alt.themes.enable("none") diff --git a/tests/vegalite/v3/tests/test_theme.py b/tests/vegalite/v3/tests/test_theme.py index 1bed75838..430c21935 100644 --- a/tests/vegalite/v3/tests/test_theme.py +++ b/tests/vegalite/v3/tests/test_theme.py @@ -15,6 +15,6 @@ def test_vega_themes(chart): dct = chart.to_dict() assert dct["usermeta"] == {"embedOptions": {"theme": theme}} assert dct["config"] == { - "view": {"width": 300, "height": 300}, + "view": {"width": 400, "height": 300}, "mark": {"tooltip": None}, } diff --git a/tests/vegalite/v4/tests/test_api.py b/tests/vegalite/v4/tests/test_api.py index a805680d6..66ec78163 100644 --- a/tests/vegalite/v4/tests/test_api.py +++ b/tests/vegalite/v4/tests/test_api.py @@ -660,13 +660,13 @@ def test_themes(): with alt.themes.enable("default"): assert chart.to_dict()["config"] == { - "view": {"continuousWidth": 300, "continuousHeight": 300} + "view": {"continuousWidth": 400, "continuousHeight": 300} } with alt.themes.enable("opaque"): assert chart.to_dict()["config"] == { "background": "white", - "view": {"continuousWidth": 300, "continuousHeight": 300}, + "view": {"continuousWidth": 400, "continuousHeight": 300}, } with alt.themes.enable("none"): diff --git a/tests/vegalite/v4/tests/test_theme.py b/tests/vegalite/v4/tests/test_theme.py index 48a1f61ae..d159d2fa7 100644 --- a/tests/vegalite/v4/tests/test_theme.py +++ b/tests/vegalite/v4/tests/test_theme.py @@ -15,5 +15,5 @@ def test_vega_themes(chart): dct = chart.to_dict() assert dct["usermeta"] == {"embedOptions": {"theme": theme}} assert dct["config"] == { - "view": {"continuousWidth": 300, "continuousHeight": 300} + "view": {"continuousWidth": 400, "continuousHeight": 300} }