Export charts as high-resolution PNG images with custom dimensions and zoom levels
Kinetix Charts provides powerful export functionality that allows you to generate high-quality PNG images of your charts. You can export at different resolutions, custom dimensions, and even with specific zoom/pan windows.
Returns a data URL that you can use programmatically:
const dataUrl = chart.getCanvasImage();// Use in an <img> tagconst img = document.createElement('img');img.src = dataUrl;// Or send to a serverfetch('/api/save-chart', { method: 'POST', body: JSON.stringify({ image: dataUrl })});
Both methods are defined in src/core/Chart.ts:908 and src/core/Chart.ts:1064 respectively. They share the same underlying rendering logic.
Control the resolution multiplier. Higher values produce sharper images:
// Standard resolution (1x)chart.downloadImage('chart-1x.png', { scale: 1 });// Retina resolution (2x) - defaultchart.downloadImage('chart-2x.png', { scale: 2 });// High resolution for print (3x)chart.downloadImage('chart-3x.png', { scale: 3 });
The default scale is 2x (retina resolution), which produces crisp images on high-DPI displays. For web use, 2x is usually sufficient. For print materials, consider 3x or higher.
Export a specific zoom or pan window of your data:
// Export only data between x: 0 and x: 50chart.downloadImage('chart-zoomed.png', { window: { xMin: 0, xMax: 50 }});// Export specific X and Y rangeschart.downloadImage('chart-window.png', { window: { xMin: 0, xMax: 100, yMin: 0, yMax: 500 }});
The window option works with numeric/index domain coordinates. It is not supported for scrollable categorical charts (see src/core/Chart.ts:940-953).
All chart layers are rendered in the correct z-index order during export, ensuring the exported image looks identical to what’s displayed on screen (see src/core/Chart.ts:1002-1010).