-
Notifications
You must be signed in to change notification settings - Fork 92
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 plot save formats #2729
Conversation
I'm working on fixing the test failure |
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.
Python changes LGTM!
const extension = path.value.fsPath.split('.').pop()?.toLowerCase(); | ||
let format = extension as PlotFormat; | ||
|
||
// default to PNG if the format is unknown |
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.
If the user gets to choose the file format in the modal, should we always use that file format regardless of the file name's extension? Or maybe we could show a validation error if those don't match? Silently defaulting to png feels like it would confuse users
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.
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've changed it to use a directory selector and separate file name field. The user selects the format. No need to check the extension anymore as it will be added for the user.
The overwrite check also occurs at save and the user can cancel if they do not wish to overwrite. Any errors during save due to write access or anything else is shown after saving and closing the dialog
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's much better!
Out of interest, I compared this with VSCode's save modal (you can get there by creating a new untitled file and then saving it). When you select a file format it updates the extension in the file name. If you use a mismatched format and extension, it shows the following error:
I wonder if we want to hook into that or if we prefer to roll our own? I don't have any personal preference. This feels like a broader Positron UX question.
* @returns A promise that resolves to a rendered image, or rejects with an error. | ||
*/ | ||
public render(height: number, width: number, pixel_ratio: number): Promise<IRenderedPlot> { | ||
public render(height: number, width: number, pixel_ratio: number, format = 'png'): Promise<IRenderedPlot> { |
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.
Will we want to remove these defaults once ARK supports the format arg?
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.
Yes, that would be good to avoid the confusion of falling back to a png when the user selected something else.
Add SVG support
Add format selector in dialog Browse now sets directory save location Add field for file name Validate path at save time Show error if saving failed
c2f45de
to
3cab731
Compare
I've opened the PR for Ark |
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.
LGTM
@jonvanausdeln I'm updating the spec to reflect the changes in choosing the file path and format. |
Intent
Address #2657
Approach
Adds a format option when selecting where to save the plot. This adds a new parameter to the render request and updates the Python extension to render the other formats. Ark will have its own PR to add in that support. Until Ark supports the other formats, plot saving will always save as a PNG regardless of the chosen format.
QA Notes
Sample plot for Python
Sample plot for R