Skip to content

Expose SeriesState for simplified charts #487

Closed

Description

@techniq

Expose SeriesState for simplified charts to enable:

  • Setting initial selected series
  • Externally controlling selection
  • Reading/writing selection to local storage, etc

Activity

  1. cycle4passion commented on Jul 11, 2025

    @cycle4passion
    Contributor

    I would also find it useful to expose BrushState for persisting in localstorage. This allows for persistence of series and selected range.

  2. techniq commented on Jul 14, 2025

    @techniq
    OwnerAuthor

    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: #605

  3. cycle4passion commented on Jul 16, 2025

    @cycle4passion
    Contributor

    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?

  4. techniq commented on Jul 16, 2025

    @techniq
    OwnerAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions