Guides
Saving and restoring
Save panes, drawings, general charts, and studies, and take screenshots.
Export and import state
Layouts
const state = chart.exportState();
localStorage.setItem("layout", JSON.stringify(state));
// later, on a fresh chart
const restored = await createChart(container, { autoSize: true });
restored.import_state(localStorage.getItem("layout"));State covers panes and drawings, general charts, and studies. It does not include market data, caches, or trading objects; load your data again after importing. Import works on a fresh chart, and throws an AerisChartsError if the state is invalid.
Limits
Imports are capped at 8 MiB, 64 panes, and 10,000 drawings. The state schema has its own version, separate from the npm version.
Screenshots
takeScreenshot
// (addTopLayer = true, includeCrosshair = true)
const canvas = chart.takeScreenshot(true, false);
canvas.toBlob((blob) => download(blob, "chart.png"));