Skip to content
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

Small improvements #393

Merged
merged 2 commits into from
Nov 14, 2024
Merged
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
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
4 changes: 1 addition & 3 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(', ')}]`);
};
}

Expand Down
Loading