Skip to content

Commit e5711c8

Browse files
Remove type augmentation application from charts codebase
1 parent cf1ce0b commit e5711c8

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

packages/x-charts/src/LineChart/useLinePlotData.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@ import { getCurveFactory } from '../internals/getCurve';
88
import { ChartsXAxisProps, ChartsYAxisProps } from '../models';
99
import { getValueToPositionMapper, useLineSeriesContext, useXAxes, useYAxes } from '../hooks';
1010
import { DEFAULT_X_AXIS_KEY } from '../constants';
11-
import { SeriesId } from '../models/seriesType/common';
12-
13-
declare module '@mui/x-charts/typeAugmentation' {
14-
interface ChartsEnabledFeature {
15-
colorCallback: true;
16-
}
17-
}
11+
import { SeriesColorProp, SeriesId } from '../models/seriesType/common';
1812

1913
interface LinePlotDataPoint {
2014
d: string;
@@ -134,7 +128,8 @@ export function useLinePlotData(
134128
.y((d) => yScale(d.y[1])!);
135129

136130
const d = linePath.curve(getCurveFactory(curve))(d3Data) || '';
137-
const seriesColor = series[seriesId].color;
131+
// FIXME: V9: remove this cast as it will no longer be necessary
132+
const seriesColor = series[seriesId].color as SeriesColorProp<number | null>;
138133
linePlotData.push({
139134
color: typeof seriesColor === 'function' ? seriesColor(null) : seriesColor,
140135
gradientId,

packages/x-charts/src/ScatterChart/ScatterPlot.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@ import { useXAxes, useYAxes } from '../hooks';
77
import { useZAxes } from '../hooks/useZAxis';
88
import { seriesConfig as scatterSeriesConfig } from './seriesConfig';
99
import { BatchScatter } from './BatchScatter';
10-
11-
declare module '@mui/x-charts/typeAugmentation' {
12-
interface ChartsEnabledFeature {
13-
colorCallback: true;
14-
}
15-
}
10+
import { SeriesColorProp } from '../models/seriesType/common';
1611

1712
export interface ScatterPlotSlots extends ScatterSlots {
1813
scatter?: React.JSXElementConstructor<ScatterProps>;
@@ -80,6 +75,9 @@ function ScatterPlot(props: ScatterPlotProps) {
8075
{seriesOrder.map((seriesId) => {
8176
const { id, xAxisId, yAxisId, zAxisId, color } = series[seriesId];
8277

78+
// FIXME: V9: remove this cast as it will no longer be necessary
79+
const seriesColor = color as SeriesColorProp<number | null>;
80+
8381
const colorGetter = scatterSeriesConfig.colorProcessor(
8482
series[seriesId],
8583
xAxis[xAxisId ?? defaultXAxisId],
@@ -93,7 +91,7 @@ function ScatterPlot(props: ScatterPlotProps) {
9391
key={id}
9492
xScale={xScale}
9593
yScale={yScale}
96-
color={typeof color === 'function' ? color(null) : color}
94+
color={typeof seriesColor === 'function' ? seriesColor(null) : seriesColor}
9795
colorGetter={colorGetter}
9896
series={series[seriesId]}
9997
onItemClick={onItemClick}

0 commit comments

Comments
 (0)