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

Change default chart width from 400 to 300 #2785

Merged
merged 5 commits into from
Jan 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions altair/vegalite/v5/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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},
}
},
)
Expand Down
4 changes: 2 additions & 2 deletions doc/user_guide/customization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -673,7 +673,7 @@ fill unless otherwise specified:
'config': {
'view': {
'height': 300,
'width': 400,
'width': 300,
},
'mark': {
'color': 'black',
Expand Down
4 changes: 2 additions & 2 deletions doc/user_guide/internals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
)
)
)
Expand Down
4 changes: 2 additions & 2 deletions doc/user_guide/large_datasets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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'}},
Expand Down Expand Up @@ -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'}},
Expand Down
6 changes: 3 additions & 3 deletions doc/user_guide/saving_charts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The contents of the resulting file will look something like this:
"config": {
"view": {
"continuousHeight": 300,
"continuousWidth": 400
"continuousWidth": 300
}
},
"data": {
Expand Down Expand Up @@ -90,7 +90,7 @@ javascript-enabled web browser:
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/vega@5"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-lite@4"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-lite@5"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-embed@6"></script>
</head>
<body>
Expand All @@ -101,7 +101,7 @@ javascript-enabled web browser:
"config": {
"view": {
"continuousHeight": 300,
"continuousWidth": 400
"continuousWidth": 300
}
},
"data": {
Expand Down
4 changes: 2 additions & 2 deletions tests/vegalite/v5/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,13 +704,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"):
Expand Down
2 changes: 1 addition & 1 deletion tests/vegalite/v5/tests/test_theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}