Skip to content

Commit

Permalink
Create PNG images with higher scale
Browse files Browse the repository at this point in the history
  • Loading branch information
Luthaf committed Nov 13, 2024
1 parent 55ed5df commit b72aeec
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/map/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,19 @@ const DEFAULT_CONFIG = {
path: extractSvgPath(PNG_SVG),
},
click: function (gd: PlotlyScatterElement) {
const width = Math.max(gd._fullLayout.width, 600);
const ratio = gd._fullLayout.height / gd._fullLayout.width;
const height = width * ratio;

Plotly.downloadImage(gd, {
filename: 'chemiscope-map',
format: 'png',
width: Math.max(gd._fullLayout.width, 600),
height: Math.max(gd._fullLayout.width, 600),
}).catch((e: unknown) =>
width: width,
height: height,
// scale is not part of `DownloadImgopts`, but accepted
// by the function anyway
scale: 3,
} as unknown as Plotly.DownloadImgopts).catch((e: unknown) =>
setTimeout(() => {
throw e;
})
Expand Down

0 comments on commit b72aeec

Please sign in to comment.