Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ js/*.tgz

# OS X
.DS_Store

MANIFEST
28 changes: 28 additions & 0 deletions js/src/mpl_widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,34 @@ export class MPLCanvasModel extends widgets.DOMWidgetModel {
}
}

generateMimeBundle() {
const width = this.offscreen_canvas.width;
const height = this.offscreen_canvas.height;

let header = '';
if (this.get('header_visible')) {
header = `
<div style="text-align: center;">${this.get('_figure_label')}</div>
`
}

return {
'text/html': `
<div>
${header}
<img src="${this.offscreen_canvas.toDataURL('image/png', 1.0)}"
width="${width}" height="${height}"
style="width: ${width / this.ratio}px; height: ${height / this.ratio}px;"/>
</div?
`
};
}

// We want the static figure to overwrite the widget mimebundle on Notebook save
shouldOverwriteMimeBundle() {
return true;
}

remove() {
this.send_message('closing');
}
Expand Down