async function renderToImageURL(type, scaleFactor) {
    if (type !== RenderType.Canvas && type !== RenderType.SVG && type !== RenderType.PNG) {
      error('Unrecognized image type: ' + type);
    }
    const r = await renderHeadless(this, type, scaleFactor);
    return type === RenderType.SVG ? toBlobURL(r.svg(), 'image/svg+xml') : r.canvas().toDataURL('image/png');
  }
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 {string} type - The image type. One of 'svg', 'png' or 'canvas'.
  The 'canvas' and 'png' types are synonyms for a PNG image.
@return {Promise} - A promise that resolves to an image URL.