-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Override toImage modebar button opts via config #2607
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -47,19 +47,29 @@ var modeBarButtons = module.exports = {}; | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| modeBarButtons.toImage = { | ||||||||||||||||||||||||
| name: 'toImage', | ||||||||||||||||||||||||
| title: function(gd) { return _(gd, 'Download plot as a png'); }, | ||||||||||||||||||||||||
| title: function(gd) { return _(gd, 'Download plot'); }, | ||||||||||||||||||||||||
| icon: Icons.camera, | ||||||||||||||||||||||||
| click: function(gd) { | ||||||||||||||||||||||||
| var format = 'png'; | ||||||||||||||||||||||||
| var toImageButtonDefaults = gd._context.toImageButtonDefaults; | ||||||||||||||||||||||||
| var opts = {format: toImageButtonDefaults.format || 'png'}; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Lib.notifier(_(gd, 'Taking snapshot - this may take a few seconds'), 'long'); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if(Lib.isIE()) { | ||||||||||||||||||||||||
| Lib.notifier(_(gd, 'IE only supports svg. Changing format to svg.'), 'long'); | ||||||||||||||||||||||||
| format = 'svg'; | ||||||||||||||||||||||||
| opts.format = 'svg'; | ||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also we should change the conditional to |
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Registry.call('downloadImage', gd, {'format': format}) | ||||||||||||||||||||||||
| if(toImageButtonDefaults.width) { | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| var format = coerce('format'); | |
| var width = coerce('width'); | |
| var height = coerce('height'); | |
| var scale = coerce('scale'); | |
| var setBackground = coerce('setBackground'); | |
| var imageDataOnly = coerce('imageDataOnly'); |
Outdated
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.
@nicolaskruchten we might as well add scale
plotly.js/src/plot_api/to_image.js
Lines 41 to 51 in 398eeb3
| scale: { | |
| valType: 'number', | |
| min: 0, | |
| dflt: 1, | |
| description: [ | |
| 'Sets a scaling for the generated image.', | |
| 'If set, all features of a graphs (e.g. text, line width)', | |
| 'are scaled, unlike simply setting', | |
| 'a bigger *width* and *height*.' | |
| ].join(' ') | |
| }, |
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.
We can't make dynamic strings here, so
_(gd, 'Download plot as a ' + format)won't work, but perhaps we can keep'Download plot as a png'as the default string and only degrade to'Download plot'if it's not a png? Two reasons: