-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Fix pie chart display when switching from notebook editor #42430
Fix pie chart display when switching from notebook editor #42430
Conversation
Codenotify: Notifying subscribers in CODENOTIFY files for diff 17852e5...b52c761.
|
|
@@ -258,11 +261,15 @@ export default class PieChart extends Component { | |||
const { width, height } = | |||
this.chartContainer.current.getBoundingClientRect(); | |||
|
|||
if (width === 0 && height === 0) { | |||
return this.updateChartViewportSize(delay + 200); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a bit hackish, it would be great to avoid that.
So the problem is that ExplicitSize in ChartWithLegend
resizes with a delay so that this updateChartViewportSize
function is invoked when chartContainer still has zero width and zero height.
I think a more straightforward and reliable approach would be to call the previous version of updateChartViewportSize
when ExplicitSize updates its size. Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the feedback! I pushed up a commit to revert the hack and update the chart viewport size when ExplicitSize updates its size.
…from-notebook-editor
@@ -21,6 +21,15 @@ class ChartWithLegend extends Component { | |||
style: {}, | |||
}; | |||
|
|||
componentDidUpdate(prevProps) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe a more suitable place for this would be right in ExplicitSize
component:
In __updateSize
we can change the line 186 to this.setState({ width, height }, () => this.props.onResize?.());
And then slightly tweak the prop you added in the PieChart: onResize={this.updateChartViewportSize}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, Sasha!
@JesseSDevaney Did you forget to add a milestone to the issue for this PR? When and where should I add a milestone? |
* fix pie chart display when switching from notebook editor * remove hack * fix missing pie chart display * fix missing pie chart display * address feedback * fix type error
…42538) * fix pie chart display when switching from notebook editor * remove hack * fix missing pie chart display * fix missing pie chart display * address feedback * fix type error Co-authored-by: Jesse Devaney <22608765+JesseSDevaney@users.noreply.github.com>
* fix pie chart display when switching from notebook editor * remove hack * fix missing pie chart display * fix missing pie chart display * address feedback * fix type error
Before
2024-05-08.17-09-22.mp4
After
2024-05-08.17-08-49.mp4