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

[docs] Fix multiple console.error messages on charts docs #14554

Merged
merged 3 commits into from
Sep 10, 2024

Conversation

JCQuintas
Copy link
Member

@JCQuintas JCQuintas added docs Improvements or additions to the documentation component: charts This is the name of the generic UI component, not the React module! labels Sep 9, 2024
@JCQuintas JCQuintas self-assigned this Sep 9, 2024
@mui-bot
Copy link

mui-bot commented Sep 9, 2024

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

Generated by 🚫 dangerJS against 9abd5b4

Copy link

codspeed-hq bot commented Sep 9, 2024

CodSpeed Performance Report

Merging #14554 will not alter performance

Comparing JCQuintas:fix-console-errors-docs (9abd5b4) with master (dd98382)

Summary

✅ 3 untouched benchmarks

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.

Nice catch :)

@@ -262,6 +262,6 @@ function getGaussianSeriesData(mean, stdev = [0.5, 0.5], N = 50) {
Math.cos(2.0 * Math.PI * chance.floating({ min: 0, max: 0.99 })) *
stdev[1] +
mean[1];
return { x, y, z: x + y, id: i };
Copy link
Member

Choose a reason for hiding this comment

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

Why adding the mean.join(',') ?

If using indexes causes key to be inconsistent, we could add the seriesId in the key than striking the demo.

Copy link
Member Author

Choose a reason for hiding this comment

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

Why adding the mean.join(',') ?

Was a quickfix for having unique ids, the index is already there, adding the mean, which is unique for every call of this function, should make the ids/keys unique overall as well.

Keep in mind these are not in multiple series, they are in a single series, hence why the key=id=i was being an issue

If using indexes causes key to be inconsistent, we could add the seriesId in the key than striking the demo.

Tbh I have no idea why we need the id, I suppose it is to prevent duplicate keys? It feels unnecessary though, like we could use an internal id instead of requiring it, but if the user provides it, we should use what they provide.

Copy link
Member

@alexfauquette alexfauquette Sep 10, 2024

Choose a reason for hiding this comment

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

Ok, I did not see that the function was called multiple time to geenrate the data array. I thaugh it it was called once per series

data: [
      ...getGaussianSeriesData([-1, -1]),
      ...getGaussianSeriesData([-1, 1]),
      ...getGaussianSeriesData([1, 1]),
      ...getGaussianSeriesData([1, -1]),
    ]

Tbh I have no idea why we need the id,

For sure we could have a default id generation. The only issue is when user start to modify their data. In such case if they do not provide ids by themself, we have no way to properly define key attribute

@@ -177,7 +177,7 @@ export default function BasicScatter() {
},
{
label: 'Series B',
data: data.map((v) => ({ x: v.x1, y: v.y2, id: v.id })),
data: data.map((v) => ({ x: v.x1, y: v.y2, id: `${v.id}b` })),
Copy link
Member

Choose a reason for hiding this comment

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

I've two questions

  • Is something preventing us to use number as an item id? I assume user with an autoincrement id will have a similar issue
  • Is their a specific reason for adding a b at the end?

Copy link
Member Author

Choose a reason for hiding this comment

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

Is something preventing us to use number as an item id?

Probably not, we would just have to ensure the numbers don't overlap, like 1000 + v.id

Is their a specific reason for adding a b at the end?

I just went with the simples way of making this work,
Series B => {id}b

Copy link
Member

@alexfauquette alexfauquette Sep 10, 2024

Choose a reason for hiding this comment

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

I do not manage to reproduce the error. I reverted the change on localhost, and I see not message in the console while playing with this demo.

I assume this one can be reverted

Copy link
Member Author

Choose a reason for hiding this comment

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

🤔 true, I suppose I got confused with the logs while doing the other scatter issue 🙃

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! docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants