Skip to content

Modebar download button auto-size image #1725

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

Closed
marcusblevin opened this issue May 25, 2017 · 1 comment
Closed

Modebar download button auto-size image #1725

marcusblevin opened this issue May 25, 2017 · 1 comment

Comments

@marcusblevin
Copy link

I would like to request the modeBarButtons.toImage function be expanded to include the current plot dimensions when creating the image.

modeBarButtons.toImage = {
name: 'toImage',
title: 'Download plot as a png',
icon: Icons.camera,
click: function(gd) {
var format = 'png';
var w = gd.offsetWidth;
var h = gd.offsetHeight;

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

    if(Lib.isIE()) {
        Lib.notifier('IE only supports svg.  Changing format to svg.', 'long');
        format = 'svg';
    }

    downloadImage(gd, {'format': format, **width: w, height: h**})
      .then(function(filename) {
          Lib.notifier('Snapshot succeeded - ' + filename, 'long');
      })
      .catch(function() {
          Lib.notifier('Sorry there was a problem downloading your snapshot!', 'long');
      });
}

};

Thanks

@etpinard
Copy link
Contributor

duplicate of #1576

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants