From b72aeecffcc690ff319c19a38f5187116dd830b6 Mon Sep 17 00:00:00 2001 From: Guillaume Fraux Date: Wed, 13 Nov 2024 18:27:30 +0100 Subject: [PATCH] Create PNG images with higher scale --- src/map/map.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/map/map.ts b/src/map/map.ts index fc9263f6c..929c109f1 100644 --- a/src/map/map.ts +++ b/src/map/map.ts @@ -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; })