<!-- Public documentation export; not library implementation source. -->
# Templates, settings and drawing storage

Templates save part of a chart's state so it can be reused. Store them separately from full layouts.

## Chart settings templates

These save appearance and settings only. They don't include the symbol, interval, panes, drawings or indicators. Before applying one, the runtime checks it against the exact current template schema. Storing chart templates needs the complete list, load, save and remove methods.

## Drawing templates

Save templates by tool and name. Only allowed style properties belong in a template. Details about a specific drawing, such as its ID, a custom title or its lifecycle state, shouldn't end up in reusable defaults. The saved template format is stricter than the options you can pass when creating a drawing.

## Study templates

Use the public API to create and apply study templates, along with the matching adapter methods. Decide up front whether a template should include the symbol and interval. A study template isn't a complete user workspace.

## User settings

For preferences that should survive the chart being recreated, use the supported settings adapter. Keep server-saved settings tied to the signed-in user, so one user's preferences never show up in someone else's session. If you don't configure an adapter, document any browser-only behavior your app depends on.

## Separate drawing storage

Storing drawings separately is optional. To use it, turn on the matching feature and provide the complete save/load contract.

### Use the official format

`getLineToolsState()` returns drawings and groups in the supported format. `applyLineToolsState(state)` checks the whole input before changing anything. Keep source IDs, groups, symbol ownership and version fields intact. Don't flatten the state into a plain list of points without a version.

The drawing format uses exact property names and a strict, current schema. Saved state is rejected if it contains nested creation `overrides`, unknown keys or alternative names. If even one item is invalid, the whole drawing payload is rejected. The chart won't quietly apply only the valid items.

### Keeping layouts in sync

Whether drawings can be shared depends on symbol ownership and layout sharing details. Group IDs stay local to one chart. Restoring can sync copies of a drawing, but don't build global IDs from list positions.

### Recovering from failures

Keep the last good saved copy until a new save succeeds. If saved data fails validation, leave the user's current chart as it is and offer a clear way to recover. Don't drop the broken items quietly and report the restore as a success.

[Drawing API](https://docs.lumencharts.com/charting-library/drawings) · [Migration policy](https://docs.lumencharts.com/charting-library/persistence/migration)

---
Documentation page: https://docs.lumencharts.com/charting-library/persistence/templates
