Skip to content

Commit

Permalink
[charts] Fix TS config (mui#11259) (mui#11260)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette authored Dec 1, 2023
1 parent 4838eb9 commit 89909d9
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 222 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"series": {
"type": {
"name": "arrayOf",
"description": "Array&lt;any<br>&#124;&nbsp;{ area?: bool, color: string, connectNulls?: bool, curve?: 'catmullRom'<br>&#124;&nbsp;'linear'<br>&#124;&nbsp;'monotoneX'<br>&#124;&nbsp;'monotoneY'<br>&#124;&nbsp;'natural'<br>&#124;&nbsp;'step'<br>&#124;&nbsp;'stepAfter'<br>&#124;&nbsp;'stepBefore', data: Array&lt;number&gt;, dataKey?: string, disableHighlight?: bool, highlightScope?: { faded?: 'global'<br>&#124;&nbsp;'none'<br>&#124;&nbsp;'series', highlighted?: 'item'<br>&#124;&nbsp;'none'<br>&#124;&nbsp;'series' }, id: string, label?: string, showMark?: func<br>&#124;&nbsp;bool, stack?: string, stackOffset?: 'diverging'<br>&#124;&nbsp;'expand'<br>&#124;&nbsp;'none'<br>&#124;&nbsp;'silhouette'<br>&#124;&nbsp;'wiggle', stackOrder?: 'appearance'<br>&#124;&nbsp;'ascending'<br>&#124;&nbsp;'descending'<br>&#124;&nbsp;'insideOut'<br>&#124;&nbsp;'none'<br>&#124;&nbsp;'reverse', type: 'line', valueFormatter: func, xAxisKey?: string, yAxisKey?: string }&gt;"
"description": "Array&lt;{ area?: bool, color: string, connectNulls?: bool, curve?: 'catmullRom'<br>&#124;&nbsp;'linear'<br>&#124;&nbsp;'monotoneX'<br>&#124;&nbsp;'monotoneY'<br>&#124;&nbsp;'natural'<br>&#124;&nbsp;'step'<br>&#124;&nbsp;'stepAfter'<br>&#124;&nbsp;'stepBefore', data: Array&lt;number&gt;, dataKey?: string, disableHighlight?: bool, highlightScope?: { faded?: 'global'<br>&#124;&nbsp;'none'<br>&#124;&nbsp;'series', highlighted?: 'item'<br>&#124;&nbsp;'none'<br>&#124;&nbsp;'series' }, id: string, label?: string, showMark?: func<br>&#124;&nbsp;bool, stack?: string, stackOffset?: 'diverging'<br>&#124;&nbsp;'expand'<br>&#124;&nbsp;'none'<br>&#124;&nbsp;'silhouette'<br>&#124;&nbsp;'wiggle', stackOrder?: 'appearance'<br>&#124;&nbsp;'ascending'<br>&#124;&nbsp;'descending'<br>&#124;&nbsp;'insideOut'<br>&#124;&nbsp;'none'<br>&#124;&nbsp;'reverse', type: 'line', valueFormatter: func, xAxisKey?: string, yAxisKey?: string }&gt;"
},
"required": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"series": {
"type": {
"name": "shape",
"description": "{ color?: string, data: Array&lt;number&gt;<br>&#124;&nbsp;{ __@iterator@33607: func, __@unscopables@36473: { __@iterator@33607?: bool, __@unscopables@36473?: bool, at?: bool, concat?: bool, copyWithin?: bool, entries?: bool, every?: bool, fill?: bool, filter?: bool, find?: bool, findIndex?: bool, findLast?: bool, findLastIndex?: bool, flat?: bool, flatMap?: bool, forEach?: bool, includes?: bool, indexOf?: bool, join?: bool, keys?: bool, lastIndexOf?: bool, length?: bool, map?: bool, pop?: bool, push?: bool, reduce?: bool, reduceRight?: bool, reverse?: bool, shift?: bool, slice?: bool, some?: bool, sort?: bool, splice?: bool, toLocaleString?: bool, toReversed?: bool, toSorted?: bool, toSpliced?: bool, toString?: bool, unshift?: bool, values?: bool, with?: bool }, at: func, concat: func, copyWithin: func, entries: func, every: func, fill: func, filter: func, find: func, findIndex: func, findLast: func, findLastIndex: func, flat: func, flatMap: func, forEach: func, includes: func, indexOf: func, join: func, keys: func, lastIndexOf: func, length: number, map: func, pop: func, push: func, reduce: func, reduceRight: func, reverse: func, shift: func, slice: func, some: func, sort: func, splice: func, toLocaleString: func, toReversed: func, toSorted: func, toSpliced: func, toString: func, unshift: func, values: func, with: func }, highlightScope?: { faded?: 'global'<br>&#124;&nbsp;'none'<br>&#124;&nbsp;'series', highlighted?: 'item'<br>&#124;&nbsp;'none'<br>&#124;&nbsp;'series' }, id: string, type: 'bar'<br>&#124;&nbsp;'line'<br>&#124;&nbsp;'pie'<br>&#124;&nbsp;'scatter', valueFormatter: func }"
"description": "{ color?: string, data: Array&lt;number&gt;, highlightScope?: { faded?: 'global'<br>&#124;&nbsp;'none'<br>&#124;&nbsp;'series', highlighted?: 'item'<br>&#124;&nbsp;'none'<br>&#124;&nbsp;'series' }, id: string, type: 'bar'<br>&#124;&nbsp;'line'<br>&#124;&nbsp;'pie'<br>&#124;&nbsp;'scatter', valueFormatter: func }"
},
"required": true
}
Expand Down
79 changes: 38 additions & 41 deletions packages/x-charts/src/ChartsTooltip/ChartsAxisTooltipContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,48 +168,45 @@ ChartsAxisTooltipContent.propTypes = {
classes: PropTypes.object,
dataIndex: PropTypes.number,
series: PropTypes.arrayOf(
PropTypes.oneOfType([
PropTypes.any,
PropTypes.shape({
area: PropTypes.bool,
color: PropTypes.string.isRequired,
connectNulls: PropTypes.bool,
curve: PropTypes.oneOf([
'catmullRom',
'linear',
'monotoneX',
'monotoneY',
'natural',
'step',
'stepAfter',
'stepBefore',
]),
data: PropTypes.arrayOf(PropTypes.number).isRequired,
dataKey: PropTypes.string,
disableHighlight: PropTypes.bool,
highlightScope: PropTypes.shape({
faded: PropTypes.oneOf(['global', 'none', 'series']),
highlighted: PropTypes.oneOf(['item', 'none', 'series']),
}),
id: PropTypes.string.isRequired,
label: PropTypes.string,
showMark: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
stack: PropTypes.string,
stackOffset: PropTypes.oneOf(['diverging', 'expand', 'none', 'silhouette', 'wiggle']),
stackOrder: PropTypes.oneOf([
'appearance',
'ascending',
'descending',
'insideOut',
'none',
'reverse',
]),
type: PropTypes.oneOf(['line']).isRequired,
valueFormatter: PropTypes.func.isRequired,
xAxisKey: PropTypes.string,
yAxisKey: PropTypes.string,
PropTypes.shape({
area: PropTypes.bool,
color: PropTypes.string.isRequired,
connectNulls: PropTypes.bool,
curve: PropTypes.oneOf([
'catmullRom',
'linear',
'monotoneX',
'monotoneY',
'natural',
'step',
'stepAfter',
'stepBefore',
]),
data: PropTypes.arrayOf(PropTypes.number).isRequired,
dataKey: PropTypes.string,
disableHighlight: PropTypes.bool,
highlightScope: PropTypes.shape({
faded: PropTypes.oneOf(['global', 'none', 'series']),
highlighted: PropTypes.oneOf(['item', 'none', 'series']),
}),
]).isRequired,
id: PropTypes.string.isRequired,
label: PropTypes.string,
showMark: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
stack: PropTypes.string,
stackOffset: PropTypes.oneOf(['diverging', 'expand', 'none', 'silhouette', 'wiggle']),
stackOrder: PropTypes.oneOf([
'appearance',
'ascending',
'descending',
'insideOut',
'none',
'reverse',
]),
type: PropTypes.oneOf(['line']).isRequired,
valueFormatter: PropTypes.func.isRequired,
xAxisKey: PropTypes.string,
yAxisKey: PropTypes.string,
}),
),
sx: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])),
Expand Down
47 changes: 1 addition & 46 deletions packages/x-charts/src/ChartsTooltip/ChartsItemTooltipContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,52 +68,7 @@ ChartsItemTooltipContent.propTypes = {
}),
series: PropTypes.shape({
color: PropTypes.string,
data: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.number),
PropTypes.shape({
'__@iterator@33607': PropTypes.func.isRequired,
'__@unscopables@36473': PropTypes.object.isRequired,
at: PropTypes.func.isRequired,
concat: PropTypes.func.isRequired,
copyWithin: PropTypes.func.isRequired,
entries: PropTypes.func.isRequired,
every: PropTypes.func.isRequired,
fill: PropTypes.func.isRequired,
filter: PropTypes.func.isRequired,
find: PropTypes.func.isRequired,
findIndex: PropTypes.func.isRequired,
findLast: PropTypes.func.isRequired,
findLastIndex: PropTypes.func.isRequired,
flat: PropTypes.func.isRequired,
flatMap: PropTypes.func.isRequired,
forEach: PropTypes.func.isRequired,
includes: PropTypes.func.isRequired,
indexOf: PropTypes.func.isRequired,
join: PropTypes.func.isRequired,
keys: PropTypes.func.isRequired,
lastIndexOf: PropTypes.func.isRequired,
length: PropTypes.number.isRequired,
map: PropTypes.func.isRequired,
pop: PropTypes.func.isRequired,
push: PropTypes.func.isRequired,
reduce: PropTypes.func.isRequired,
reduceRight: PropTypes.func.isRequired,
reverse: PropTypes.func.isRequired,
shift: PropTypes.func.isRequired,
slice: PropTypes.func.isRequired,
some: PropTypes.func.isRequired,
sort: PropTypes.func.isRequired,
splice: PropTypes.func.isRequired,
toLocaleString: PropTypes.func.isRequired,
toReversed: PropTypes.func.isRequired,
toSorted: PropTypes.func.isRequired,
toSpliced: PropTypes.func.isRequired,
toString: PropTypes.func.isRequired,
unshift: PropTypes.func.isRequired,
values: PropTypes.func.isRequired,
with: PropTypes.func.isRequired,
}),
]).isRequired,
data: PropTypes.arrayOf(PropTypes.number).isRequired,
highlightScope: PropTypes.shape({
faded: PropTypes.oneOf(['global', 'none', 'series']),
highlighted: PropTypes.oneOf(['item', 'none', 'series']),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,48 +132,45 @@ DefaultChartsAxisTooltipContent.propTypes = {
* The series linked to the triggered axis.
*/
series: PropTypes.arrayOf(
PropTypes.oneOfType([
PropTypes.any,
PropTypes.shape({
area: PropTypes.bool,
color: PropTypes.string.isRequired,
connectNulls: PropTypes.bool,
curve: PropTypes.oneOf([
'catmullRom',
'linear',
'monotoneX',
'monotoneY',
'natural',
'step',
'stepAfter',
'stepBefore',
]),
data: PropTypes.arrayOf(PropTypes.number).isRequired,
dataKey: PropTypes.string,
disableHighlight: PropTypes.bool,
highlightScope: PropTypes.shape({
faded: PropTypes.oneOf(['global', 'none', 'series']),
highlighted: PropTypes.oneOf(['item', 'none', 'series']),
}),
id: PropTypes.string.isRequired,
label: PropTypes.string,
showMark: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
stack: PropTypes.string,
stackOffset: PropTypes.oneOf(['diverging', 'expand', 'none', 'silhouette', 'wiggle']),
stackOrder: PropTypes.oneOf([
'appearance',
'ascending',
'descending',
'insideOut',
'none',
'reverse',
]),
type: PropTypes.oneOf(['line']).isRequired,
valueFormatter: PropTypes.func.isRequired,
xAxisKey: PropTypes.string,
yAxisKey: PropTypes.string,
PropTypes.shape({
area: PropTypes.bool,
color: PropTypes.string.isRequired,
connectNulls: PropTypes.bool,
curve: PropTypes.oneOf([
'catmullRom',
'linear',
'monotoneX',
'monotoneY',
'natural',
'step',
'stepAfter',
'stepBefore',
]),
data: PropTypes.arrayOf(PropTypes.number).isRequired,
dataKey: PropTypes.string,
disableHighlight: PropTypes.bool,
highlightScope: PropTypes.shape({
faded: PropTypes.oneOf(['global', 'none', 'series']),
highlighted: PropTypes.oneOf(['item', 'none', 'series']),
}),
]).isRequired,
id: PropTypes.string.isRequired,
label: PropTypes.string,
showMark: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
stack: PropTypes.string,
stackOffset: PropTypes.oneOf(['diverging', 'expand', 'none', 'silhouette', 'wiggle']),
stackOrder: PropTypes.oneOf([
'appearance',
'ascending',
'descending',
'insideOut',
'none',
'reverse',
]),
type: PropTypes.oneOf(['line']).isRequired,
valueFormatter: PropTypes.func.isRequired,
xAxisKey: PropTypes.string,
yAxisKey: PropTypes.string,
}),
).isRequired,
sx: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,94 +78,7 @@ DefaultChartsItemTooltipContent.propTypes = {
*/
series: PropTypes.shape({
color: PropTypes.string,
data: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.number),
PropTypes.shape({
'__@iterator@33607': PropTypes.func.isRequired,
'__@unscopables@36473': PropTypes.shape({
'__@iterator@33607': PropTypes.bool,
'__@unscopables@36473': PropTypes.bool,
at: PropTypes.bool,
concat: PropTypes.bool,
copyWithin: PropTypes.bool,
entries: PropTypes.bool,
every: PropTypes.bool,
fill: PropTypes.bool,
filter: PropTypes.bool,
find: PropTypes.bool,
findIndex: PropTypes.bool,
findLast: PropTypes.bool,
findLastIndex: PropTypes.bool,
flat: PropTypes.bool,
flatMap: PropTypes.bool,
forEach: PropTypes.bool,
includes: PropTypes.bool,
indexOf: PropTypes.bool,
join: PropTypes.bool,
keys: PropTypes.bool,
lastIndexOf: PropTypes.bool,
length: PropTypes.bool,
map: PropTypes.bool,
pop: PropTypes.bool,
push: PropTypes.bool,
reduce: PropTypes.bool,
reduceRight: PropTypes.bool,
reverse: PropTypes.bool,
shift: PropTypes.bool,
slice: PropTypes.bool,
some: PropTypes.bool,
sort: PropTypes.bool,
splice: PropTypes.bool,
toLocaleString: PropTypes.bool,
toReversed: PropTypes.bool,
toSorted: PropTypes.bool,
toSpliced: PropTypes.bool,
toString: PropTypes.bool,
unshift: PropTypes.bool,
values: PropTypes.bool,
with: PropTypes.bool,
}).isRequired,
at: PropTypes.func.isRequired,
concat: PropTypes.func.isRequired,
copyWithin: PropTypes.func.isRequired,
entries: PropTypes.func.isRequired,
every: PropTypes.func.isRequired,
fill: PropTypes.func.isRequired,
filter: PropTypes.func.isRequired,
find: PropTypes.func.isRequired,
findIndex: PropTypes.func.isRequired,
findLast: PropTypes.func.isRequired,
findLastIndex: PropTypes.func.isRequired,
flat: PropTypes.func.isRequired,
flatMap: PropTypes.func.isRequired,
forEach: PropTypes.func.isRequired,
includes: PropTypes.func.isRequired,
indexOf: PropTypes.func.isRequired,
join: PropTypes.func.isRequired,
keys: PropTypes.func.isRequired,
lastIndexOf: PropTypes.func.isRequired,
length: PropTypes.number.isRequired,
map: PropTypes.func.isRequired,
pop: PropTypes.func.isRequired,
push: PropTypes.func.isRequired,
reduce: PropTypes.func.isRequired,
reduceRight: PropTypes.func.isRequired,
reverse: PropTypes.func.isRequired,
shift: PropTypes.func.isRequired,
slice: PropTypes.func.isRequired,
some: PropTypes.func.isRequired,
sort: PropTypes.func.isRequired,
splice: PropTypes.func.isRequired,
toLocaleString: PropTypes.func.isRequired,
toReversed: PropTypes.func.isRequired,
toSorted: PropTypes.func.isRequired,
toSpliced: PropTypes.func.isRequired,
toString: PropTypes.func.isRequired,
unshift: PropTypes.func.isRequired,
values: PropTypes.func.isRequired,
with: PropTypes.func.isRequired,
}),
]).isRequired,
data: PropTypes.arrayOf(PropTypes.number).isRequired,
highlightScope: PropTypes.shape({
faded: PropTypes.oneOf(['global', 'none', 'series']),
highlighted: PropTypes.oneOf(['item', 'none', 'series']),
Expand Down
2 changes: 1 addition & 1 deletion packages/x-charts/src/ScatterChart/Scatter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Scatter.propTypes = {
color: PropTypes.string.isRequired,
markerSize: PropTypes.number.isRequired,
series: PropTypes.shape({
color: PropTypes.string,
color: PropTypes.string.isRequired,
data: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
Expand Down
7 changes: 5 additions & 2 deletions packages/x-charts/src/models/seriesType/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ export type ChartSeries<T extends ChartSeriesType> = ChartsSeriesConfig[T] exten
? ChartsSeriesConfig[T]['seriesInput'] & { stackedData: [number, number][] }
: ChartsSeriesConfig[T]['seriesInput'];

export type ChartSeriesDefaultized<T extends ChartSeriesType> = ChartsSeriesConfig[T]['series'] &
ChartSeries<T>;
export type ChartSeriesDefaultized<T extends ChartSeriesType> = ChartsSeriesConfig[T] extends {
canBeStacked: true;
}
? ChartsSeriesConfig[T]['series'] & { stackedData: [number, number][] }
: ChartsSeriesConfig[T]['series'];

export type ChartItemIdentifier<T extends ChartSeriesType> =
ChartsSeriesConfig[T]['itemIdentifier'];
Expand Down
2 changes: 1 addition & 1 deletion packages/x-charts/src/models/seriesType/scatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ export type ScatterItemIdentifier = {
};

export interface DefaultizedScatterSeriesType
extends DefaultizedProps<ScatterSeriesType, CommonDefaultizedProps> {}
extends DefaultizedProps<ScatterSeriesType, CommonDefaultizedProps | 'color'> {}

0 comments on commit 89909d9

Please sign in to comment.