MCPcopy
hub / github.com/antvis/Infographic / toDataURL

Method toDataURL

src/runtime/Infographic.tsx:189–197  ·  view source on GitHub ↗

* Export the infographic to data URL * @param options Export option * @returns Data URL string of the exported infographic * @description This method need to be called after `render()` and in a browser environment.

(options?: ExportOptions)

Source from the content-addressed store, hash-verified

187 * @description This method need to be called after `render()` and in a browser environment.
188 */
189 async toDataURL(options?: ExportOptions): Promise<string> {
190 if (!this.node) {
191 throw new Error('Infographic is not rendered yet.');
192 }
193 if (options?.type === 'svg') {
194 return await exportToSVGString(this.node, options);
195 }
196 return await exportToPNGString(this.node, options);
197 }
198
199 on(event: string, listener: (...args: any[]) => void) {
200 this.emitter.on(event, listener);

Callers 3

downloadFunction · 0.80
exportToPNGStringFunction · 0.80
Infographic.tsxFile · 0.80

Calls 2

exportToSVGStringFunction · 0.90
exportToPNGStringFunction · 0.90

Tested by

no test coverage detected