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

new(xychart): make DataProvider optional #913

Merged
merged 3 commits into from
Nov 5, 2020
Merged

Conversation

williaster
Copy link
Collaborator

@williaster williaster commented Nov 4, 2020

🚀 Enhancements

This PR adds a usability improvement to @visx/xychart, making it optional for package consumers to render DataProvider which is arguably an internal implementation detail (note that it is already optional for consumers to render TooltipProvider and EventEmitterProvider).

Users can still render DataProvider up the parent chain for advanced use cases like linked charts, where it's desirable to share a single DataContext.

// before (still valid)
() => (
  <DataProvider xScale={..} yScale={..} theme={..}>
    <XYChart width={..} height={..}>
      {...}
    </XYChart>
  </DataProvider>
)

// after
() => (
  <XYChart 
    xScale={..} 
    yScale={..} 
    theme={..}
    width={..} 
    height={..}
  >
    {...}
  </XYChart>
)

Testing

  • new jest tests
  • verified that /xychart demo is still functional

)}
{renderBarSeries && (
<XYChart theme={theme} xScale={config.x} yScale={config.y} height={Math.min(400, height)}>
<CustomChartBackground />
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

💬 only DataProvider was removed, everything else in this file is a de-indentation

</XYChart>,
),
// eslint-disable-next-line jest/require-to-throw-message
).toThrow();
Copy link
Collaborator Author

@williaster williaster Nov 4, 2020

Choose a reason for hiding this comment

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

💬 this throws only because nimbus transforms console.warns to throw

@coveralls
Copy link

Pull Request Test Coverage Report for Build 344801060

  • 6 of 7 (85.71%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.09%) to 60.182%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/visx-xychart/src/components/XYChart.tsx 6 7 85.71%
Totals Coverage Status
Change from base Build 344463151: 0.09%
Covered Lines: 1554
Relevant Lines: 2451

💛 - Coveralls

@williaster williaster merged commit 2f54108 into master Nov 5, 2020
@williaster williaster deleted the chris--xychart-provider branch November 5, 2020 19:19
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.

3 participants