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

[chart] Use default values instead of non-null assertion to prevent error being thrown #13637

Merged
merged 6 commits into from
Jun 27, 2024

Conversation

JCQuintas
Copy link
Member

Some cleanup related to #13405 but moved here to make that PR cleaner

@JCQuintas JCQuintas added enhancement This is not a bug, nor a new feature component: charts This is the name of the generic UI component, not the React module! labels Jun 26, 2024
@JCQuintas JCQuintas self-assigned this Jun 26, 2024
@mui-bot
Copy link

mui-bot commented Jun 26, 2024

Deploy preview: https://deploy-preview-13637--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against 27a2c0a

return (
<React.Fragment>
{xAxisHighlight === 'band' && axis.x !== null && isBandScale(xScale) && (
<ChartsAxisHighlightPath
d={`M ${xScale(axis.x.value)! - (xScale.step() - xScale.bandwidth()) / 2} ${
d={`M ${(xScale(axis.x.value) ?? 0) - (xScale.step() - xScale.bandwidth()) / 2} ${
Copy link
Member

Choose a reason for hiding this comment

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

If xScale(axis.x.value) is not defined, Maybe it would make more sense not to render this component instead of placing it at coordinate 0

Copy link
Member Author

Choose a reason for hiding this comment

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

I went with rendering at 0 because it would be clearer that something is wrong, rather than silently failing. Though I don't have a strong preference

Copy link
Member

Choose a reason for hiding this comment

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

What about logging a warning?

This should not append, but I think it's better to have a non working features that logs in the console why it's not working

Copy link
Member Author

Choose a reason for hiding this comment

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

🤔 Wait I did something wrong 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed 👍

return (
<React.Fragment>
{xAxisHighlight === 'band' && axis.x !== null && isBandScale(xScale) && (
<ChartsAxisHighlightPath
d={`M ${xScale(axis.x.value)! - (xScale.step() - xScale.bandwidth()) / 2} ${
d={`M ${(xScale(axis.x.value) ?? 0) - (xScale.step() - xScale.bandwidth()) / 2} ${
Copy link
Member

Choose a reason for hiding this comment

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

What about logging a warning?

This should not append, but I think it's better to have a non working features that logs in the console why it's not working

packages/x-charts/src/internals/getSVGPoint.ts Outdated Show resolved Hide resolved
JCQuintas and others added 2 commits June 27, 2024 11:04
Co-authored-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com>
Signed-off-by: Jose C Quintas Jr <juniorquintas@gmail.com>
Copy link
Member

@alexfauquette alexfauquette left a comment

Choose a reason for hiding this comment

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

Just a nitpick. Otherwise it's a nice refactoring 👍

@JCQuintas JCQuintas enabled auto-merge (squash) June 27, 2024 12:02
@JCQuintas JCQuintas merged commit 8380f86 into mui:master Jun 27, 2024
15 checks passed
@JCQuintas JCQuintas deleted the charts-improvements-for-zoom branch June 27, 2024 12:19
DungTiger pushed a commit to DungTiger/mui-x that referenced this pull request Jul 23, 2024
…rror being thrown (mui#13637)

Signed-off-by: Jose C Quintas Jr <juniorquintas@gmail.com>
Co-authored-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com>
thomasmoon pushed a commit to thomasmoon/mui-x that referenced this pull request Sep 9, 2024
…rror being thrown (mui#13637)

Signed-off-by: Jose C Quintas Jr <juniorquintas@gmail.com>
Co-authored-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: charts This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants