victory icon indicating copy to clipboard operation
victory copied to clipboard

Turbo: data aggregator

Open scottrippey opened this issue 2 years ago • 4 comments

What

This "data aggregator" approach is to replace the Context-based approach currently used by the Turbo refactor.

The problem

Victory components can be nested inside a parent container:

<VictoryChart>
  <VictoryLine data={data} />
  <VictoryBar data={data} />
  <VictoryScatter data={data} />
</VictoryChart>

The parent container, in this example, needs to aggregate all the data from the children, to determine the range, domain, scale, etc.

In the current Turbo refactor, we did this via Context; each child reports its data to the parent. This happens in a useLayoutEffect, which suffers from major drawbacks -- primarily that it breaks SSR support.

The "Data Aggregator" Approach

This approach is derived from Victory's pre-Turbo behavior. When a parent is rendered, it will actually traverse the children and aggregate all data before rendering. This works with SSR, and prevents unneeded rerendering.

This also gives us a chance to normalize the data, and provide a simple API for accessing "normalized" data.

scottrippey avatar Aug 22 '22 22:08 scottrippey

@scottrippey Do we have additional work to do here?

carbonrobot avatar Nov 15 '23 17:11 carbonrobot

@carbonrobot This PoC is complete. The approach worked great, but this only applies to the turbo refactor. I suggest we get this merged, as it vastly improves the turbo codebase. Then we can decide what to do with it along with the rest of turbo.

scottrippey avatar Nov 16 '23 14:11 scottrippey

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
victory ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 16, 2023 9:40pm

vercel[bot] avatar Nov 16 '23 21:11 vercel[bot]

⚠️ No Changeset found

Latest commit: d0e93fd8d554c4f487f30755d09c9299cb6d97b9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Nov 16 '23 21:11 changeset-bot[bot]