Code Monkey home page Code Monkey logo

Comments (3)

ijlyttle avatar ijlyttle commented on May 30, 2024

image

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.

ijlyttle avatar ijlyttle commented on May 30, 2024

The more I read about this, the more confused I get.

There seem to be two ways in which the sizing issue gets resolved:

  1. The container tells the chart how big it can be, using the width and height arguments in vegalite(). I can see this working using the autosize 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.

  2. The chart tells the container how big it can be - by leaving vegalite() width and height 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() and result.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.

ijlyttle avatar ijlyttle commented on May 30, 2024

Confusion subsiding (I think)

To settle these issues, I propose that:

  1. 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 the vegalite.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");
  1. If vegalite() is called with non-null values for either width or height, then these values are set in the chart's view configuration. Further, some values are set in the chart's autosize configuration: contains = "padding" and type = "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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.