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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(xychart): add AreaStack tests #1036

Merged

Conversation

williaster
Copy link
Collaborator

🏠 Internal

This adds tests for useStackedData and AreaStack added in #1019

🐛 Bug Fix

In the process of adding tests I fixed two DataProvider issues which can result in invalid scales on initial render:

  • an invalid object spread in useDimensions could result in width, height, or margin being undefined upon initialization, resulting in invalid scale.range
  • d3 scales initialized with domain: [] result in domain = [NaN, NaN], which previously could happen when no data was present in the data registry (now we defer scale initialization until data is present)

@kristw @hshoff

@@ -66,7 +66,11 @@ export default function BaseAxis<Scale extends AxisScale>({
? (width ?? 0) - (margin?.right ?? 0)
: 0;

return (
const scale = (orientation === 'left' || orientation === 'right' ? yScale : xScale) as
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would this look cleaner?
const scale: Scale | undefined = ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Definitely ideal, but the type won't work without a coercion either here, or when I get the scales from DataContext (I haven't successfully figured out how to use generics with Context types; most Series coerce the Context values right now)

@williaster williaster mentioned this pull request Jan 26, 2021
2 tasks
@williaster williaster merged commit 40c3855 into chris--xychart-stacked-areas Jan 26, 2021
@williaster williaster deleted the chris--xychart-areastack-tests branch January 26, 2021 20:14
williaster added a commit that referenced this pull request Jan 26, 2021
* 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 added a commit that referenced this pull request Jan 26, 2021
* new(xychart): mid AreaStack addition

* new(xychart/useStackedData): improve logic for all stack offsets

* new(xychart): add working polished AreaStack, AnimatedAreaStack

* lint(xychart/private/BaseAreaStack)

* fix(demo/xychart): fix BaseAreaStack import

* fix(xychart/stack): fix component names + comment copy

* test(xychart): add AreaStack tests (#1036)

* 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

* test(xychart): fix tests to handle undefined scales
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants