-
-
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] Introduce plugins system #13367
Conversation
Deploy preview: https://deploy-preview-13367--material-ui-x.netlify.app/ |
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 |
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.
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']
}
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'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
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
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, | ||
}), |
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 proptype seem overly verbose 😅
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.
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> |
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.
Is this todo meant to be in?
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.
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) |
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.
* 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) |
Followup of #13366 extracted from #13209