* 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)
| 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); |
no test coverage detected