* Produce an image URL for the visualization. Depending on the type * parameter, the generated URL contains data for either a PNG or SVG image. * The URL can be used (for example) to download images of the visualization. * This method is asynchronous, returning a Promise instance. * @param {stri
(type, scaleFactor)
| 142252 | * The 'canvas' and 'png' types are synonyms for a PNG image. |
| 142253 | * @return {Promise} - A promise that resolves to an image URL. |
| 142254 | */ async function renderToImageURL(type, scaleFactor) { |
| 142255 | if (type !== (0, _vegaScenegraph.RenderType).Canvas && type !== (0, _vegaScenegraph.RenderType).SVG && type !== (0, _vegaScenegraph.RenderType).PNG) (0, _vegaUtil.error)("Unrecognized image type: " + type); |
| 142256 | const r = await renderHeadless(this, type, scaleFactor); |
| 142257 | return type === (0, _vegaScenegraph.RenderType).SVG ? toBlobURL(r.svg(), "image/svg+xml") : r.canvas().toDataURL("image/png"); |
| 142258 | } |
| 142259 | function toBlobURL(data2, mime) { |
| 142260 | const blob = new Blob([ |
| 142261 | data2 |
nothing calls this directly
no test coverage detected