Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

feat: add error boundary and responsiveness to SuperChart #175

Merged
merged 14 commits into from
Jun 18, 2019

Conversation

kristw
Copy link
Contributor

@kristw kristw commented Jun 13, 2019

馃彔 Internal

  • Rename former SuperChart class to SuperChartCore.
  • Add @vx/responsive type declaration.

馃弳 Enhancements

Create new class SuperChart that wraps SuperChartCore.
Create another new class SuperChartShell to wrap SuperChart and provide backward-compatibility API. This can be removed in the upcoming breaking change.
SuperChartShell is exported as SuperChart and provide 100% backward-compatibility.

  • Provide ErrorBoundary, which can be disabled if needed.
  • Allow users to specify width height as number or dynamic value such as 100%.
  • Support spreading chartProps fields to top-level.

Before

This behavior is still supported, but less preferred.

<SuperChart chartProps={new ChartProps({ width: 400, height: 400, formData: {a: 1} })} />

Enhancement#1 Support plain object as chartProps

This format was used in many Storybooks, although it will show error once the story is converted to typescript. With this PR, the pattern is now legit.

<SuperChart chartProps={{ width: 400, height: 400, formData: {a: 1} }} />

Enhancement#2 Can list the fields as props to SuperChart

The new preferred way, which should be more natural.

<SuperChart width={400} height={400} formData={{a: 1}} />

See the storybook preview. Can use knobs to adjust width and height.

image

This one shows error boundary.

image

@kristw kristw requested a review from a team as a code owner June 13, 2019 07:26
@kristw kristw changed the title feat: add error boundary and responsiveness to SuperChart [WIP] feat: add error boundary and responsiveness to SuperChart Jun 13, 2019
@codecov
Copy link

codecov bot commented Jun 13, 2019

Codecov Report

Merging #175 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #175   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          90     94    +4     
  Lines        1123   1157   +34     
  Branches      268    276    +8     
=====================================
+ Hits         1123   1157   +34
Impacted Files Coverage 螖
...ackages/superset-ui-chart/src/models/ChartProps.ts 100% <酶> (酶) 猬嗭笍
...rset-ui-chart/test/components/MockChartPlugins.tsx 100% <100%> (酶) 猬嗭笍
...uperset-ui-chart/src/components/SuperChartCore.tsx 100% <100%> (酶)
...perset-ui-chart/test/components/promiseTimeout.tsx 100% <100%> (酶)
...rset-ui-chart/src/components/FallbackComponent.tsx 100% <100%> (酶)
...es/superset-ui-chart/src/components/SuperChart.tsx 100% <100%> (酶) 猬嗭笍
...perset-ui-chart/src/components/SuperChartShell.tsx 100% <100%> (酶)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update 54849c1...5c49d27. Read the comment docs.

@netlify
Copy link

netlify bot commented Jun 13, 2019

Deploy preview for superset-ui ready!

Built with commit 5c49d27

https://deploy-preview-175--superset-ui.netlify.com

@kristw kristw changed the title [WIP] feat: add error boundary and responsiveness to SuperChart feat: add error boundary and responsiveness to SuperChart Jun 13, 2019
@kristw kristw added the reviewable Ready for review label Jun 13, 2019
@kristw kristw added the #enhancement New feature or request label Jun 13, 2019
@kristw
Copy link
Contributor Author

kristw commented Jun 17, 2019

This PR is ready for review

Copy link
Contributor

@williaster williaster left a comment

Choose a reason for hiding this comment

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

LGTM overall! had a couple comments about possibly simplifying the API/questions about the API going forward.


export default class SuperChart extends React.PureComponent<SuperChartProps, {}> {
export default class SuperChart extends React.PureComponent<Props, {}> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Kernel makes this a little less understandable/more complex IMO, Base or Core seems a little more approachable 馃

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renaming to xxxCore

};

/** SuperChart Props for version 0.11 and below has chartProps */
type ClassicProps = Omit<SuperChartKernelProps, 'chartProps'> & {
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to support both prop types? with a breaking version couldn't we just change to the new API?

or if you want to keep them around for a version, could we instead only support the new API in this component, and add a wrapper that just spreads chartProps to simplify this component?

@kristw kristw merged commit c17b13d into master Jun 18, 2019
@delete-merged-branch delete-merged-branch bot deleted the kristw--super2 branch June 18, 2019 00:35
kristw added a commit that referenced this pull request Apr 17, 2020
* feat: update type for line chart series

* fix: another place
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
#enhancement New feature or request reviewable Ready for review size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants