Chart sizing through custom theme doesn't work
See original GitHub issueHello Altair community, I am trying to set the width and height of chart through theme setting, however it doesn’t seem to be working. Am I setting the wrong keys or is this a bug? Please see below for detail:
# custom theme
def long_chart():
return {
'view': {
'width' : 500,
'height' : 150
}
}
alt.themes.register('long_chart', long_chart)
with alt.themes.enable('long_chart'):
chart1 = alt.Chart(population).mark_point().encode(
x='year:O',
y='sum(people)',
color='sex:N'
).properties(
title='Chart sizing thru custom theme'
)
chart2 = alt.Chart(
population,
width=500,
height=150).mark_point().encode(
x='year:O',
y='sum(people)',
color='sex:N'
).properties(
title='Chart sizing thru Chart()'
)
chart1 | chart2
I was expecting chart1
to look exactly the same as chart2
.
Looking at the json spec of chart1
, it seems that the width and height is still the default value:
chart1.to_dict()
{'config': {'view': {'width': 400, 'height': 300}},
'data': {'name': 'data-45e35b5faa42c7034b347e8bcfc8b805'},
'mark': 'point',
'encoding': {'color': {'type': 'nominal', 'field': 'sex'},
'x': {'type': 'ordinal', 'field': 'year'},
'y': {'type': 'quantitative', 'aggregate': 'sum', 'field': 'people'}},
'title': 'Chart sizing thru custom theme',
'$schema': 'https://vega.github.io/schema/vega-lite/v2.6.0.json',
'datasets': {'data-45e35b5faa42c7034b347e8bcfc8b805': [{'age': 0,
'people': 1483789,
'sex': 1,
'year': 1850},
{'age': 0, 'people': 1450376, 'sex': 2, 'year': 1850},
...
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Shopify tutorial on size chart doesn't work (using a free theme)
Re: Shopify tutorial on size chart doesn't work (using a free theme) · 1. Go to Online Store > Actions > Edit Code....
Read more >Custome Theme doesnt overwrite changes made in the report
Hi,. i preapared simple global rule to change fonts on all charts. ... Unfortunately when i import it into PowerBI Desktop it changes...
Read more >Increasing font size with a custom theme - Qlik Community
I've been able to adjust the title font size by following the instructions found at . This code works to adjust the title...
Read more >How to get a custom design theme for your visualizations
The charts, maps, and tables you create with Datawrapper can be fully customized to fit in with your organization's design style guide. To...
Read more >Motion Support: How do I set up a product size chart?
Setup your size chart block Open the theme editor and navigate to a ... Create new alternate product templates by selecting Products in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
And note that themes, and configuration settings in general, can only be applied to top-level charts. There is no way in Vega-Lite to set different global configuration options for different sub-charts.
When exiting the context manager, the settings are reset, even for saved charts. I do not know if it is normal, but you can see it this way
Created on 2018-11-19 by the reprexpy package