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

[charts] Introduce plugins system #13367

Merged
merged 6 commits into from
Jun 6, 2024

Conversation

alexfauquette
Copy link
Member

Followup of #13366 extracted from #13209

@alexfauquette alexfauquette added the component: charts This is the name of the generic UI component, not the React module! label Jun 4, 2024
@mui-bot
Copy link

mui-bot commented Jun 4, 2024

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

Generated by 🚫 dangerJS against 7dd85de

const plugin = defaultizedPlugins[i];

// To remove those any we will need to solve this union discrimination issue:
// https://www.typescriptlang.org/play/?#code/FDAuE8AcFMAIDkCuBbARtATgYQPYDsAzASwHNYBeWAb2FlgGsi8ATALlgHI8V0MOBuWrBwwMAQ1A4M7ABQAPdtzSYAlBQB8sJb0EBfEBBiwAyqAxMSuQqQrUhjFuw4BnMxYFCRmCVNkLYruZ4JGrkmoEWeiAAxviuWqhWxCTsSMrY+Mm2VAxMbLAARNqYBQA0wqI+0rByGrAATLAAVDWw+rF48YFJpOymQZaZNpQ5DvkFEcFlFd6S1bVhsAAG9S0AJFRyukttMXGgsB3JzrYA2niJQyTl3VcAugZQcADylXPOALJikJAW2ULFDAAflSPEwPRIpw4XnEcw4d1KQkmJBBJjcwQhUJhVXhiN0gmAHXi2LmXx+FnYr1mUk+31+wWy+JABCksBkABtoAcjjYcARDldnGoaCA6AB6MWwADqUnoJxw9FgRH5AHc4L9ooroGJogALQ5iZxwPJEABuRGYiDE7PASJVRFAerZPJIADoxsKhHRooa4FwwXxWF66DNYVIyfTIS73Xk7rZoySpIIQyHUBhtfRkyGfUbOMiOEGU3RExgIxZTtGxnHKAm3kng8xoAQxIh2aBC0W0xms-pvftqLkWOUS2141chBLYABJDimuB4HBKxtiWBiVA4RAHXU4FWwSSwTkHAAqxlgiBYmFcYhYAusbrGq5vtepGFX6YPTHo0GYnjrpbp5ZVrYJZ6EAA
Copy link
Member

Choose a reason for hiding this comment

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

furthest I could get quickly is this, it solves the assignment type issue operatorMapping[kind] = operator, but doesn't solve accessing operatorMapping[kind]() typing issue :(

type OperatorsMapping<T extends NumberConfig | StringConfig= NumberConfig | StringConfig> = {
  [k in T['kind']]?: T['operator']
}

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'm not sure it's feasible, but does not matter a lot. As long as the type constraint in the input/output of the hook are ok, it should not cause any issue

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 5, 2024
Copy link

github-actions bot commented Jun 5, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 5, 2024
Comment on lines 154 to 182
PropTypes.oneOfType([
PropTypes.shape({
colorProcessor: PropTypes.func.isRequired,
seriesFormatter: PropTypes.func.isRequired,
seriesType: PropTypes.oneOf(['bar']).isRequired,
xExtremumGetter: PropTypes.func,
yExtremumGetter: PropTypes.func,
}),
PropTypes.shape({
colorProcessor: PropTypes.func.isRequired,
seriesFormatter: PropTypes.func.isRequired,
seriesType: PropTypes.oneOf(['line']).isRequired,
xExtremumGetter: PropTypes.func,
yExtremumGetter: PropTypes.func,
}),
PropTypes.shape({
colorProcessor: PropTypes.func.isRequired,
seriesFormatter: PropTypes.func.isRequired,
seriesType: PropTypes.oneOf(['scatter']).isRequired,
xExtremumGetter: PropTypes.func,
yExtremumGetter: PropTypes.func,
}),
PropTypes.shape({
colorProcessor: PropTypes.func.isRequired,
seriesFormatter: PropTypes.func.isRequired,
seriesType: PropTypes.oneOf(['pie']).isRequired,
xExtremumGetter: PropTypes.func,
yExtremumGetter: PropTypes.func,
}),
Copy link
Member

Choose a reason for hiding this comment

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

this proptype seem overly verbose 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, could be removed :)

I think I did it in the main PR, but forgot to extract it 👍

line: lineSeriesFormatter,
pie: pieSeriesFormatter,
export type SeriesFormatterConfig<T extends ChartSeriesType = ChartSeriesType> = {
// TODO replace the function type by Formatter<K>
Copy link
Member

Choose a reason for hiding this comment

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

Is this todo meant to be in?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not in this PR, because it impacts such a big part of the codebase that it would require a dedicated PR

@@ -10,7 +10,7 @@ import { SeriesId } from './common';
export interface ChartsSeriesConfig {
bar: {
/**
* Series type when passed to the formatter (some ids are defaultised to simplify the DX)
* Series type when passed to the formatter (some ids are defaultized to simplify the DX)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Series type when passed to the formatter (some ids are defaultized to simplify the DX)
* Series type when passed to the formatter (some ids are given default values to simplify the DX)

packages/x-charts/src/models/plugin.ts Show resolved Hide resolved
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!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants