Expose `SeriesState` for simplified charts
Expose SeriesState for simplified charts to enable:
- Setting initial selected series
- Externally controlling selection
- Reading/writing selection to local storage, etc
I would also find it useful to expose BrushState for persisting in localstorage. This allows for persistence of series and selected range.
I would also find it useful to expose BrushState for persisting in localstorage. This allows for persistence of series and selected range.
100% agree, and actually started on this a bit ago and need to resume. Encapsulating the state in a new BrushState class will enable and simplify state management (this is a pattern I plan to lean into with more state management). Also looking at supporting band scales and fixing some element click interop.
Progress here: https://github.com/techniq/layerchart/pull/605
In addition to exposing SereisState, BrushState, others, what about a prop like ...
<Chart persist="localStorage" / >
and Layerchart goes ahead and does the heavy lifting read/write to localStorage or sessionStorage?
In addition to exposing SereisState, BrushState, others, what about a prop like ...
<Chart persist="localStorage" / >
and Layerchart goes ahead and does the heavy lifting read/write to localStorage or sessionStorage?
Hmm... we would need to generate a unique ID per chart instance (could use $props.id()).
Initially I would prefer to have some callback hooks, similar to SvelteKit snapshots (capture / restore) and leave it to the user where the would like to persist (localStorage, sessionStorage, query string, API/db call, etc).
I think we approach this iteratively - expose the state, expose the hooks, and then maybe add convenient adapters if needed.