-
Notifications
You must be signed in to change notification settings - Fork 0
Support non-SVG snapshots when using MS Edge #2
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
base: master
Are you sure you want to change the base?
Conversation
be2a09a
to
ee427b1
Compare
This looks very good! Can we also push it up to the modebar download button? I'm thinking remove this block and instead in the catch look for the IE error we just threw and try again with svg? The downside of that approach is it will make modebar button downloads take longer on IE, because you have to do a lot of the work twice. I think that may be acceptable, but if we wanted to avoid it we could either a) look for a quick way to trigger that same Once this includes the modebar button, feel free to make a PR to the main plotly.js repo. |
D'oh, I hadn't tested the download button yet as I'm using a custom button directly invoking Doing the work twice is not likely to be a huge penalty in time performance, but I wonder if the statefulness will be tricky to manage -- in order to avoid a "Snapshotting in progress..." situation on the second attempt. I'll try it and see. Option A seems like a better approach over browser sniffing. It might be worth adding a predicate to |
No worries, that's what reviews are for! Anyway the
If that's easy to do, then absolutely, sounds like the best route! |
Quick question: does |
@@ -18,20 +18,6 @@ function svgToImg(opts) { | |||
var Image = window.Image; | |||
var svg = opts.svg; | |||
var format = opts.format || 'png'; | |||
|
|||
// IE only support svg | |||
if(Lib.isIE() && format !== 'svg') { |
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.
So this means Lib.isIE
returns true in Edge? Is there an easy way to fix that? We could add an Lib.isMSbrowser
if ever we need IE+Edge logic.
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'd frankly vote to go for explicit feature detection - rename the current Lib.isIE
to something like usesMsSaveBlob
, and detect other stuff as needed like @arbscht's suggested canExportFromCanvas
.
image export is currently the only place we use Lib.isIE
anyway.
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.
Was any more headway ever made on this issue? Would be nice to export non-SVG for Edge browser |
Allows non-SVG snapshots when using MS Edge (but not IE).
Adds:
filesaver.js
try
/catch
aroundcanvas.toDataURL
invocation insvgtoimg.js
and specially handlesSecurityError
(only anticipated in IE but not Edge); also catches generic errorsRemoves:
download.js
svgtoimg.js