-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add other formats for plot save #311
Conversation
Support PNG, SVG, PDF, and JPEG
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really an expert on these but this seems reasonable to me
/// The requested plot format | ||
pub format: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel somewhat strongly that this should be an enum of the 4 currently valid format types! I think that would make things more type safe and clear (even if we have to convert to string when eventually handing off to R, that's totally fine)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be really nice to add as another task. I'll have to update the comms definition and the Python extension after regenerating. I'll put up another PR for it.
), | ||
"svg" = grDevices::svg( | ||
filename = filepath, | ||
width = (width / 72), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind adding a comment above the switch(
call about why we do / 72
?
height = height, | ||
res = res, | ||
type = type | ||
switch( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the exact same switch(
as above?
If so, can you extract the repeated switch(
statement out into a helper, like renderPlotWithDevice()
or something
Co-authored-by: Davis Vaughan <davis@rstudio.com>
Address posit-dev/positron#2657
UI PR: posit-dev/positron#2729
During my testing, I had trouble saving SVG until I installed XQuartz. I'm not sure if R users will find this to be a problem on Mac. It seems that it's not common to use
grDevices::svg()
to save as SVG.