Skip to content

Commit 139a02a

Browse files
[charts] Remove unused generics from bar charts (#20642)
1 parent afd0065 commit 139a02a

File tree

6 files changed

+21
-25
lines changed

6 files changed

+21
-25
lines changed

packages/x-charts/src/BarChart/BarLabel/BarLabel.types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface BarLabelOwnerState {
1313
classes?: Partial<BarLabelClasses>;
1414
}
1515

16-
export type BarItem<V extends BarValueType | null = BarValueType | null> = {
16+
export type BarItem = {
1717
/**
1818
* The series id of the bar.
1919
*/
@@ -25,7 +25,7 @@ export type BarItem<V extends BarValueType | null = BarValueType | null> = {
2525
/**
2626
* The value of the data point.
2727
*/
28-
value: V;
28+
value: BarValueType | null;
2929
};
3030

3131
export type BarLabelContext = {
@@ -43,7 +43,7 @@ export type BarLabelContext = {
4343
};
4444
};
4545

46-
export type BarLabelFunction<V extends BarValueType | null = BarValueType | null> = (
47-
item: BarItem<V>,
46+
export type BarLabelFunction = (
47+
item: BarItem,
4848
context: BarLabelContext,
4949
) => string | null | undefined;

packages/x-charts/src/BarChart/BarLabel/BarLabelItem.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ export type BarLabelItemProps<V extends BarValueType | null> = Omit<
7979
* @param {BarLabelContext} context data about the bar.
8080
* @returns {string} The formatted label.
8181
*/
82-
barLabel?:
83-
| 'value'
84-
| ((item: BarItem<V>, context: BarLabelContext) => string | null | undefined);
82+
barLabel?: 'value' | ((item: BarItem, context: BarLabelContext) => string | null | undefined);
8583
/**
8684
* The placement of the bar label.
8785
* It controls whether the label is rendered in the center or outside the bar.

packages/x-charts/src/BarChart/BarLabel/BarLabelPlot.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,34 @@ import type { SeriesId } from '../../models/seriesType/common';
55
import { type BarSeriesType, type BarValueType } from '../../models/seriesType/bar';
66
import { type BarLabelFunction } from './BarLabel.types';
77

8-
interface BarLabelPlotProps<V extends BarValueType | null = BarValueType | null> {
9-
processedSeries: ProcessedBarLabelSeriesData<V>;
8+
interface BarLabelPlotProps {
9+
processedSeries: ProcessedBarLabelSeriesData;
1010
className: string;
1111
skipAnimation?: boolean;
12-
barLabel?: BarLabelItemProps<V | null>['barLabel'];
12+
barLabel?: BarLabelItemProps<BarValueType | null>['barLabel'];
1313
}
1414

15-
export interface ProcessedBarLabelSeriesData<V extends BarValueType | null> {
15+
export interface ProcessedBarLabelSeriesData {
1616
seriesId: SeriesId;
17-
data: ProcessedBarLabelData<V>[];
18-
barLabel?: 'value' | BarLabelFunction<V>;
17+
data: ProcessedBarLabelData[];
18+
barLabel?: 'value' | BarLabelFunction;
1919
barLabelPlacement?: BarSeriesType['barLabelPlacement'];
2020
layout?: 'vertical' | 'horizontal';
2121
xOrigin: number;
2222
yOrigin: number;
2323
}
2424

25-
export interface ProcessedBarLabelData<V extends BarValueType | null> extends AnimationData {
25+
export interface ProcessedBarLabelData extends AnimationData {
2626
seriesId: SeriesId;
2727
dataIndex: number;
2828
color: string;
29-
value: V;
29+
value: BarValueType | null;
3030
}
3131

3232
/**
3333
* @ignore - internal component.
3434
*/
35-
function BarLabelPlot<V extends BarValueType | null = BarValueType | null>(
36-
props: BarLabelPlotProps<V>,
37-
) {
35+
function BarLabelPlot(props: BarLabelPlotProps) {
3836
const { processedSeries, className, skipAnimation, ...other } = props;
3937
const { seriesId, data, layout, xOrigin, yOrigin } = processedSeries;
4038

packages/x-charts/src/BarChart/BarLabel/getBarLabel.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { type SeriesId } from '../../models/seriesType/common';
22
import { type BarLabelFunction } from './BarLabel.types';
33
import { type BarValueType } from '../../models/seriesType/bar';
44

5-
export function getBarLabel<V extends BarValueType | null = BarValueType | null>(options: {
6-
barLabel: 'value' | BarLabelFunction<V>;
7-
value: V;
5+
export function getBarLabel(options: {
6+
barLabel: 'value' | BarLabelFunction;
7+
value: BarValueType | null;
88
dataIndex: number;
99
seriesId: SeriesId;
1010
height: number;

packages/x-charts/src/BarChart/BarPlot.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
44
import { styled } from '@mui/material/styles';
55
import { barElementClasses } from './barElementClasses';
66
import { BarElement, type BarElementSlotProps, type BarElementSlots } from './BarElement';
7-
import { type BarItemIdentifier, type BarValueType } from '../models';
7+
import { type BarItemIdentifier } from '../models';
88
import { useDrawingArea, useXAxes, useYAxes } from '../hooks';
99
import { BarClipPath } from './BarClipPath';
1010
import { type BarLabelSlotProps, type BarLabelSlots } from './BarLabel/BarLabelItem';
@@ -160,7 +160,7 @@ function BarPlot(props: BarPlotProps) {
160160
);
161161
})}
162162
{completedData.map((processedSeries) => (
163-
<BarLabelPlot<BarValueType | null>
163+
<BarLabelPlot
164164
key={processedSeries.seriesId}
165165
className={classes.seriesLabels}
166166
processedSeries={processedSeries}

packages/x-charts/src/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { type AllSeriesType } from '../../../models/seriesType';
22

3-
export function getSeriesWithDefaultValues<T extends 'bar'>(
4-
seriesData: AllSeriesType<T>,
3+
export function getSeriesWithDefaultValues(
4+
seriesData: AllSeriesType<'bar'>,
55
seriesIndex: number,
66
colors: readonly string[],
77
) {

0 commit comments

Comments
 (0)