Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

new(xychart): add AreaStack #1019

Merged
merged 8 commits into from
Jan 26, 2021
Merged

new(xychart): add AreaStack #1019

merged 8 commits into from
Jan 26, 2021

Conversation

williaster
Copy link
Collaborator

@williaster williaster commented Jan 13, 2021

馃殌 Enhancements

This closes #994 and

  • adds an AreaStack series to support stacked areas + stream graphs
  • consolidates BarStack and AreaStack logic in a new useStackedData hook

馃悰 Bug Fix

  • fixes scale domain logic in useStackedData for different stack offsets (e.g., wiggle for streamgraphs; only diverging and none worked previously)

TODO (separate PRs to keep size down)

Preview images from the demo branch:

Basic

Tab-able tooltip

Stack offsets

@hshoff @kristw


const barSeriesChildren = useMemo(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all this logic is the same for AreaStack and is moved to useStackedData

}, [combinedData, dataKeys, order, offset]);

// update the domain to account for the (directional) stacked value
const comprehensiveDomain = useMemo(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of this is unchanged except comprehensiveDomain is now computed post-stacking because different stack offsets yield different data ranges.

@coveralls
Copy link

coveralls commented Jan 25, 2021

Pull Request Test Coverage Report for Build 513437350

  • 85 of 90 (94.44%) changed or added relevant lines in 15 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.3%) to 61.749%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/visx-xychart/src/components/series/private/AnimatedPath.tsx 2 3 66.67%
packages/visx-xychart/src/components/series/private/BaseAreaStack.tsx 35 39 89.74%
Totals Coverage Status
Change from base Build 513216295: 0.3%
Covered Lines: 1786
Relevant Lines: 2753

馃挍 - Coveralls

) as unknown) as DataContextType<XScale, YScale, StackDatum>;

// find series children
// @TODO: memoization doesn't work well if at all for this
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean by doesn't work well? still slow?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or is it because the equality check doesn't work well for children

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

equality check doesn't work with children, so I think basically everything in this hook is always re-run. I can probably optimize it with refs to the child data arrays (which would still break if users have inline data but hopefully not).

I plan to follow up on this in another PR with tests for it.

) as unknown) as DataContextType<XScale, YScale, StackDatum>;

// find series children
// @TODO: memoization doesn't work well if at all for this
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or is it because the equality check doesn't work well for children

);

// if scales and data are not available in the registry, bail
if (dataKeys.some(key => dataRegistry.get(key) == null) || !xScale || !yScale || !colorScale) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps move the !xScale || !yScale || !colorScale check before the dataKeys.some because they are cheaper. Although dataKeys is negligibly small.

williaster and others added 7 commits January 26, 2021 12:32
* fix(xychart/BaseAxis): handle undefined scale

* fix(xychart/useDimensions): fix partial initialDimensions

* new(xychart/useScales): avoid NaN domain when no values are present

* fix(xychart/DataProvider): no negative ranges or dimensions

* fix(xychart/getScaleBandwidth): handle undefined scale case

* test(xychart): add AreaStack, useStackedData tests
@williaster williaster merged commit 59ded3f into master Jan 26, 2021
XYChart automation moved this from Reviewable to Done Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
XYChart
  
Done
Development

Successfully merging this pull request may close these issues.

feature request(xychart): add stacked area series
3 participants