Comments (3)
Perhaps a more-useful way to think of this is as building (or buildings) on a plot of land.
The chart-spec tells us how big the building (or buildings for compound charts) will be. The vegalite()
function tells htmlwidgets how big shall be the plot of land.
The challenge, it seems, is to find a sensible way to ensure that the plot of land is sized appropriately to the buildings.
I think we should focus on the information from the chart-spec, and the width
and height
arguments passing through vegalite()
. We should ignore (and encourage our users to ignore) the vega_embed()
arguments for width
and height
.
from altair.
The more I read about this, the more confused I get.
There seem to be two ways in which the sizing issue gets resolved:
-
The container tells the chart how big it can be, using the
width
andheight
arguments invegalite()
. I can see this working using theautosize
parameter in Vega-Lite. This would be possible only for single or layered charts. Also, this would seem to be a use-case for the htmlwidgets resize functionality. -
The chart tells the container how big it can be - by leaving
vegalite()
width
andheight
as NULL. I am struggling with this one, as there are two issues for which I cannot yet see a way through:
-
Some JavaScript method for asking Vega-Lite "how big would you be if you were rendered right now?". In JavaScript
result.view.width()
andresult.view.width()
return the width and height from the specification, which is a different thing than we are looking for. -
The action links (export, source, editor) are a different thing from the chart, and would have to be taken into account, somehow.
from altair.
Confusion subsiding (I think)
To settle these issues, I propose that:
- In all cases, the Vega-Lite chart will determine how the size of its containing element. I propose to implement this by adding these lines to the
vegaEmbed
function, found in thevegalite.js
htmlwidgets file:
// By removing the style (width and height) of the
// enclosing element, we let the "chart" decide the space it
// will occupy.
//
el.removeAttribute("style");
- If
vegalite()
is called with non-null values for eitherwidth
orheight
, then these values are set in the chart's view configuration. Further, some values are set in the chart's autosize configuration:contains = "padding"
andtype = "fit"
. This has the effect of saying "the size of the rendered chart, including axes and padding, shall be as specified". This is effective only for single-view charts and layered charts.
The width
and height
specifications do not take into account the presence of action-links (export, source, editor).
from altair.
Related Issues (20)
- Release altair 4.1.1
- Cannot go to the vega editor from an altair plot in Rstudio HOT 2
- update documentation HOT 2
- use Altair 4.2.0
- use vegawidget 0.4
- update actions for check and pkgdown HOT 1
- use CRAN version of vegawidget
- Release altair 4.2.1
- Fix CRAN problems
- fix vignette examples
- Release altair 4.2.2
- update actions
- update URL
- update documentation
- update to lastest (Python) Altair
- Release altair 4.2.3
- docs: update gallery
- docs: describe both venv and conda installation
- deps: use devel version of vegawidget
- chore: update DESCRIPTION, README
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from altair.