-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[charts] Allow dataset
to be used with ScatterChart
#14915
Conversation
Deploy preview: https://deploy-preview-14915--material-ui-x.netlify.app/ Updated pages: |
CodSpeed Performance ReportMerging #14915 will not alter performanceComparing Summary
|
@JCQuintas I like your idea of Another more flexible option could be to introduce a |
Yeah, a function is more flexible. We should probably migrate into functions eventually though, but I didn't feel confident to do so now 😅 |
But are you ok to update the PR with |
yep |
const data = !hasStringKeys | ||
? (seriesData.data ?? []) | ||
: (dataset?.map((d) => { | ||
const x = d[xDataKey!]!; | ||
const y = d[yDataKey!]!; | ||
const z = d[zDataKey ?? '']; | ||
const id = d[idDataKey!]!; | ||
|
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.
Since datasetKeys
should contain x, y, and id if defined, some !
could be removed
const data = !hasStringKeys | |
? (seriesData.data ?? []) | |
: (dataset?.map((d) => { | |
const x = d[xDataKey!]!; | |
const y = d[yDataKey!]!; | |
const z = d[zDataKey ?? '']; | |
const id = d[idDataKey!]!; | |
const data = !seriesData?.datasetKeys | |
? (seriesData.data ?? []) | |
: (dataset?.map((d) => { | |
const x = d[seriesData?.datasetKeys.x]; | |
const y = d[seriesData?.datasetKeys.y]; | |
const z = seriesData?.datasetKeys && d[seriesData?.datasetKeys.z]; | |
const id = d[seriesData?.datasetKeys.id]; | |
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.
Its kind of required still
const x = d[seriesData?.datasetKeys!.x];
const y = d[seriesData?.datasetKeys!.y];
const z = seriesData?.datasetKeys?.z && d[seriesData?.datasetKeys!.z!];
const id = d[seriesData?.datasetKeys!.id];
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've made it closer to my initial solution, but made it cleaner, so we don't need all those !
😅
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 added a commit to extract the datasetKeys
to avoid all those seriesData?.datasetKeys
. And instead of getting a boolean, I get the list of missing properties to have a more precise error message.
I also updated the docs demo to avoid overflow between y-axis ticks and the label
Co-authored-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com> Signed-off-by: Jose C Quintas Jr <juniorquintas@gmail.com>
Resolves #14333
Uses a single object signature. As it more accurately leverage typescript to force users to provide all keys when the object exists.