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

Pass arguments to webr::canvas() graphics device during captureR() #399

Merged
merged 3 commits into from
Apr 3, 2024

Conversation

georgestagg
Copy link
Member

@georgestagg georgestagg commented Apr 2, 2024

Fixes #390.

@coatless What do you think of this implementation? Here in addition to accepting captureGraphics: true or false, optional arguments can be passed to the graphics device in the following way:

const shelter = await new webR.Shelter();
const capture = await shelter.captureR("hist(rnorm(1000))", {
  captureGraphics: {
    width: 504,
    height: 252,
  }
});

Passing an object here implies capture: true. This should allow for evaluation-level setting of graphics device options without having to start the device manually in the provided R code.

Additionally move cleanup `dev.off()` statements to `finally` block
to ensure graphics device cleanup even on evaluation error.
@coatless
Copy link
Contributor

coatless commented Apr 2, 2024

@georgestagg loving the new graphics capture options with built-in backward compatibility.

Thanks for even adding in a check to fetchwebr::canvas()!

@georgestagg georgestagg marked this pull request as ready for review April 3, 2024 08:22
@georgestagg georgestagg merged commit a06b0bb into main Apr 3, 2024
5 checks passed
@georgestagg georgestagg deleted the graphics-arguments branch April 3, 2024 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting image height/width under new capture output
2 participants