Export functionality for generating images, PDFs, SVG output, and server-side rendering capabilities.
Export charts as images in various formats.
interface EChartsType {
/**
* Get chart as data URL (base64 encoded image)
* @param opts - Export options
* @returns Data URL string
*/
getDataURL(opts?: DataURLOptions): string;
/**
* Render chart to canvas element
* @param opts - Render options
* @returns Canvas element
*/
renderToCanvas(opts?: RenderOptions): HTMLCanvasElement;
/**
* Render chart to SVG string
* @param opts - Render options
* @returns SVG string
*/
renderToSVGString(opts?: RenderOptions): string;
}
interface DataURLOptions {
/** Image type (default: 'png') */
type?: 'png' | 'jpeg' | 'svg';
/** Pixel ratio for high-DPI (default: 1) */
pixelRatio?: number;
/** Background color */
backgroundColor?: string;
/** Components to exclude from export */
excludeComponents?: string[];
}
interface RenderOptions {
/** Pixel ratio for high-DPI */
pixelRatio?: number;
/** Background color */
backgroundColor?: string;
}Usage Example:
// Export as PNG data URL
const pngDataURL = chart.getDataURL({
type: 'png',
pixelRatio: 2,
backgroundColor: '#fff'
});
// Export as SVG
const svgString = chart.renderToSVGString();
// Export to canvas for further processing
const canvas = chart.renderToCanvas({ pixelRatio: 2 });Export multiple connected charts as a single image.
/**
* Get data URL for all connected charts in a group
* @param opts - Export options for connected charts
* @returns Data URL containing all connected charts
*/
function getConnectedDataURL(opts?: ConnectedDataURLOptions): string;
interface ConnectedDataURLOptions extends DataURLOptions {
/** Layout configuration for multiple charts */
connectedBackgroundColor?: string;
}