Skip to content

Commit e7ef7ae

Browse files
PR feedback
1 parent 56c5cca commit e7ef7ae

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

src/components/modebar/buttons.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,28 @@ var modeBarButtons = module.exports = {};
4747

4848
modeBarButtons.toImage = {
4949
name: 'toImage',
50-
title: function(gd) { return _(gd, 'Download plot'); },
50+
title: function(gd) {
51+
var opts = gd._context.toImageButtonOptions || {};
52+
var format = opts.format || 'png';
53+
return format === 'png' ?
54+
_(gd, 'Download plot as a png') : // legacy text
55+
_(gd, 'Download plot'); // generic non-PNG text
56+
},
5157
icon: Icons.camera,
5258
click: function(gd) {
53-
var toImageButtonDefaults = gd._context.toImageButtonDefaults;
54-
var opts = {format: toImageButtonDefaults.format || 'png'};
59+
var toImageButtonOptions = gd._context.toImageButtonOptions;
60+
var opts = {format: toImageButtonOptions.format || 'png'};
5561

5662
Lib.notifier(_(gd, 'Taking snapshot - this may take a few seconds'), 'long');
5763

58-
if(Lib.isIE()) {
64+
if(opts.format !== 'svg' && Lib.isIE()) {
5965
Lib.notifier(_(gd, 'IE only supports svg. Changing format to svg.'), 'long');
6066
opts.format = 'svg';
6167
}
6268

6369
['filename', 'width', 'height', 'scale'].forEach(function(key) {
64-
if(toImageButtonDefaults[key]) {
65-
opts[key] = toImageButtonDefaults[key];
70+
if(toImageButtonOptions[key]) {
71+
opts[key] = toImageButtonOptions[key];
6672
}
6773
});
6874

src/plot_api/plot_config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ module.exports = {
118118
// statically override options for toImage modebar button
119119
// allowed keys are format, filename, width, height, scale
120120
// see ./components/modebar/buttons.js
121-
toImageButtonDefaults: {},
121+
toImageButtonOptions: {},
122122

123123
// add the plotly logo on the end of the mode bar
124124
displaylogo: true,

test/jasmine/tests/modebar_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ describe('ModeBar', function() {
788788

789789
it('should accept overriding defaults', function(done) {
790790
Plotly.plot(gd, {data: [], layout: {}, config: {
791-
toImageButtonDefaults: {
791+
toImageButtonOptions: {
792792
format: 'svg',
793793
filename: 'x',
794794
unsupported: 'should not pass'

0 commit comments

Comments
 (0)