From 55ed5df8da59457655cd9ff1e1c3e835ab60f394 Mon Sep 17 00:00:00 2001 From: Guillaume Fraux Date: Wed, 13 Nov 2024 17:04:41 +0100 Subject: [PATCH 1/2] Better error message for invalid settings --- src/options.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/options.ts b/src/options.ts index 34ca757aa..5681cfce9 100644 --- a/src/options.ts +++ b/src/options.ts @@ -81,9 +81,7 @@ export function optionValidator(valid: string[], name = ''): (value: string) => if (valid.includes(value)) { return; } - throw Error( - `invalid property '${value}' for ${name}, are you sure the settings correspond to the current dataset?` - ); + throw Error(`invalid value '${value}' for ${name}, expected one of [${valid.join(', ')}]`); }; } From b72aeecffcc690ff319c19a38f5187116dd830b6 Mon Sep 17 00:00:00 2001 From: Guillaume Fraux Date: Wed, 13 Nov 2024 18:27:30 +0100 Subject: [PATCH 2/2] 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; })