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 = {};
4747
4848modeBarButtons . toImage = {
4949 name : 'toImage' ,
50- title : function ( gd ) { return _ ( gd , 'Download plot as a png ' ) ; } ,
50+ title : function ( gd ) { return _ ( gd , 'Download plot' ) ; } ,
5151 icon : Icons . camera ,
5252 click : function ( gd ) {
53- var format = 'png' ;
53+ var toImageButtonDefaults = gd . _context . toImageButtonDefaults ;
54+ var opts = { format : toImageButtonDefaults . format || 'png' } ;
5455
5556 Lib . notifier ( _ ( gd , 'Taking snapshot - this may take a few seconds' ) , 'long' ) ;
5657
5758 if ( Lib . isIE ( ) ) {
5859 Lib . notifier ( _ ( gd , 'IE only supports svg. Changing format to svg.' ) , 'long' ) ;
59- format = 'svg' ;
60+ opts . format = 'svg' ;
6061 }
6162
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 )
6373 . then ( function ( filename ) {
6474 Lib . notifier ( _ ( gd , 'Snapshot succeeded' ) + ' - ' + filename , 'long' ) ;
6575 } )
Original file line number Diff line number Diff line change @@ -115,6 +115,10 @@ module.exports = {
115115 */
116116 modeBarButtons : false ,
117117
118+ // statically override options for toImage modebar button
119+ // allowed keys are format, filename, width, height
120+ toImageButtonDefaults : { } ,
121+
118122 // add the plotly logo on the end of the mode bar
119123 displaylogo : true ,
120124
You can’t perform that action at this time.
0 commit comments