Skip to content

Commit 52b38e3

Browse files
Revert className in text measurement
1 parent 871e1d6 commit 52b38e3

File tree

3 files changed

+3
-20
lines changed

3 files changed

+3
-20
lines changed

packages/x-charts/src/ChartsXAxis/ChartsXAxis.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ type LabelExtraData = { width: number; height: number; skipLabel?: boolean };
3737
function addLabelDimension(
3838
xTicks: TickItemType[],
3939
{
40-
tickLabelClassName: className,
4140
tickLabelStyle: style,
4241
tickLabelInterval,
4342
// FIXME: Define the default value in the correct place
@@ -46,7 +45,6 @@ function addLabelDimension(
4645
isMounted,
4746
}: Pick<ChartsXAxisProps, 'tickLabelInterval' | 'tickLabelStyle'> &
4847
Pick<AxisDefaultized<ScaleName, any, ChartsXAxisProps>, 'reverse' | 'minTickLabelGap'> & {
49-
tickLabelClassName?: string;
5048
isMounted: boolean;
5149
},
5250
): (TickItemType & LabelExtraData)[] {
@@ -55,7 +53,6 @@ function addLabelDimension(
5553
return { ...tick, width: 0, height: 0 };
5654
}
5755
const tickSizes = getWordsByLines({
58-
className,
5956
style,
6057
needsComputation: true,
6158
text: tick.formattedValue,
@@ -189,7 +186,6 @@ function ChartsXAxis(inProps: ChartsXAxisProps) {
189186
});
190187

191188
const xTicksWithDimension = addLabelDimension(xTicks, {
192-
tickLabelClassName: axisTickLabelProps.className,
193189
tickLabelStyle: axisTickLabelProps.style,
194190
tickLabelInterval,
195191
reverse,

packages/x-charts/src/internals/domUtils.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,7 @@ let domCleanTimeout: NodeJS.Timeout | undefined;
104104
* @param style The style applied
105105
* @returns width and height of the text
106106
*/
107-
export const getStringSize = (
108-
text: string | number,
109-
{ className = '', style = {} }: { className?: string; style?: React.CSSProperties },
110-
) => {
107+
export const getStringSize = (text: string | number, style: React.CSSProperties = {}) => {
111108
if (text === undefined || text === null || isSsr()) {
112109
return { width: 0, height: 0 };
113110
}
@@ -134,7 +131,6 @@ export const getStringSize = (
134131
// https://en.wikipedia.org/wiki/Content_Security_Policy
135132
const measurementSpanStyle: Record<string, any> = { ...SPAN_STYLE, ...style };
136133

137-
measurementSpan.className = className;
138134
Object.keys(measurementSpanStyle).map((styleKey) => {
139135
(measurementSpan!.style as Record<string, any>)[camelToMiddleLine(styleKey)] =
140136
autoCompleteStyle(styleKey, measurementSpanStyle[styleKey]);

packages/x-charts/src/internals/getWordsByLines.ts

+2-11
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ export interface ChartsTextStyle extends React.CSSProperties {
1212
}
1313

1414
export interface GetWordsByLinesParams {
15-
/**
16-
* CSS class applied to text elements.
17-
*/
18-
className?: string;
1915
/**
2016
* Text displayed.
2117
*/
@@ -31,14 +27,9 @@ export interface GetWordsByLinesParams {
3127
needsComputation?: boolean;
3228
}
3329

34-
export function getWordsByLines({
35-
className,
36-
style,
37-
needsComputation,
38-
text,
39-
}: GetWordsByLinesParams) {
30+
export function getWordsByLines({ style, needsComputation, text }: GetWordsByLinesParams) {
4031
return text.split('\n').map((subText) => ({
4132
text: subText,
42-
...(needsComputation ? getStringSize(subText, { className, style }) : { width: 0, height: 0 }),
33+
...(needsComputation ? getStringSize(subText, style) : { width: 0, height: 0 }),
4334
}));
4435
}

0 commit comments

Comments
 (0)