File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -47,19 +47,29 @@ var modeBarButtons = module.exports = {};
47
47
48
48
modeBarButtons . toImage = {
49
49
name : 'toImage' ,
50
- title : function ( gd ) { return _ ( gd , 'Download plot as a png ' ) ; } ,
50
+ title : function ( gd ) { return _ ( gd , 'Download plot' ) ; } ,
51
51
icon : Icons . camera ,
52
52
click : function ( gd ) {
53
- var format = 'png' ;
53
+ var toImageButtonDefaults = gd . _context . toImageButtonDefaults ;
54
+ var opts = { format : toImageButtonDefaults . format || 'png' } ;
54
55
55
56
Lib . notifier ( _ ( gd , 'Taking snapshot - this may take a few seconds' ) , 'long' ) ;
56
57
57
58
if ( Lib . isIE ( ) ) {
58
59
Lib . notifier ( _ ( gd , 'IE only supports svg. Changing format to svg.' ) , 'long' ) ;
59
- format = 'svg' ;
60
+ opts . format = 'svg' ;
60
61
}
61
62
62
- Registry . call ( 'downloadImage' , gd , { 'format' : format } )
63
+ if ( toImageButtonDefaults . width ) {
64
+ opts . width = toImageButtonDefaults . width ;
65
+ }
66
+ if ( toImageButtonDefaults . height ) {
67
+ opts . height = toImageButtonDefaults . height ;
68
+ }
69
+ if ( toImageButtonDefaults . filename ) {
70
+ opts . filename = toImageButtonDefaults . filename ;
71
+ }
72
+ Registry . call ( 'downloadImage' , gd , opts )
63
73
. then ( function ( filename ) {
64
74
Lib . notifier ( _ ( gd , 'Snapshot succeeded' ) + ' - ' + filename , 'long' ) ;
65
75
} )
Original file line number Diff line number Diff line change @@ -115,6 +115,10 @@ module.exports = {
115
115
*/
116
116
modeBarButtons : false ,
117
117
118
+ // statically override options for toImage modebar button
119
+ // allowed keys are format, filename, width, height
120
+ toImageButtonDefaults : { } ,
121
+
118
122
// add the plotly logo on the end of the mode bar
119
123
displaylogo : true ,
120
124
You can’t perform that action at this time.
0 commit comments