blob: 8c63a9b26220f81c0c21946498b045686a5e58bf [file] [log] [blame]
import type { Chart } from "chart.js";
export async function saveToClipboard(chart: Chart): Promise<void> {
const image = chart.toBase64Image('image/png', 1);
return fetch(image)
.then(response => response.blob())
.then((blob: Blob) => {
const type = blob.type;
return new ClipboardItem({
[type]: blob
});
}).then(item => navigator.clipboard.write([item]));
}