Skip to content
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] Remove xAxisKey, yAxisKey, and zAxisKey #15192

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions docs/pages/x/api/charts/bar-series-type.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
"stackOrder": { "type": { "description": "StackOrderType" }, "default": "'none'" },
"valueFormatter": { "type": { "description": "SeriesValueFormatter<TValue>" } },
"xAxisId": { "type": { "description": "string" } },
"xAxisKey": { "type": { "description": "string" } },
"yAxisId": { "type": { "description": "string" } },
"yAxisKey": { "type": { "description": "string" } }
"yAxisId": { "type": { "description": "string" } }
}
}
4 changes: 1 addition & 3 deletions docs/pages/x/api/charts/line-series-type.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
"stackOrder": { "type": { "description": "StackOrderType" }, "default": "'none'" },
"valueFormatter": { "type": { "description": "SeriesValueFormatter<TValue>" } },
"xAxisId": { "type": { "description": "string" } },
"xAxisKey": { "type": { "description": "string" } },
"yAxisId": { "type": { "description": "string" } },
"yAxisKey": { "type": { "description": "string" } }
"yAxisId": { "type": { "description": "string" } }
}
}
5 changes: 1 addition & 4 deletions docs/pages/x/api/charts/scatter-series-type.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
"markerSize": { "type": { "description": "number" } },
"valueFormatter": { "type": { "description": "SeriesValueFormatter<TValue>" } },
"xAxisId": { "type": { "description": "string" } },
"xAxisKey": { "type": { "description": "string" } },
"yAxisId": { "type": { "description": "string" } },
"yAxisKey": { "type": { "description": "string" } },
"zAxisId": { "type": { "description": "string" } },
"zAxisKey": { "type": { "description": "string" } }
"zAxisId": { "type": { "description": "string" } }
}
}
4 changes: 1 addition & 3 deletions docs/translations/api-docs/charts/bar-series-type.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
"description": "Formatter used to render values in tooltip or other data display."
},
"xAxisId": { "description": "The id of the x-axis used to render the series." },
"xAxisKey": { "description": "The id of the x-axis used to render the series." },
"yAxisId": { "description": "The id of the y-axis used to render the series." },
"yAxisKey": { "description": "The id of the y-axis used to render the series." }
"yAxisId": { "description": "The id of the y-axis used to render the series." }
}
}
4 changes: 1 addition & 3 deletions docs/translations/api-docs/charts/line-series-type.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
"description": "Formatter used to render values in tooltip or other data display."
},
"xAxisId": { "description": "The id of the x-axis used to render the series." },
"xAxisKey": { "description": "The id of the x-axis used to render the series." },
"yAxisId": { "description": "The id of the y-axis used to render the series." },
"yAxisKey": { "description": "The id of the y-axis used to render the series." }
"yAxisId": { "description": "The id of the y-axis used to render the series." }
}
}
5 changes: 1 addition & 4 deletions docs/translations/api-docs/charts/scatter-series-type.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
"description": "Formatter used to render values in tooltip or other data display."
},
"xAxisId": { "description": "The id of the x-axis used to render the series." },
"xAxisKey": { "description": "The id of the x-axis used to render the series." },
"yAxisId": { "description": "The id of the y-axis used to render the series." },
"yAxisKey": { "description": "The id of the y-axis used to render the series." },
"zAxisId": { "description": "The id of the z-axis used to render the series." },
"zAxisKey": { "description": "The id of the z-axis used to render the series." }
"zAxisId": { "description": "The id of the z-axis used to render the series." }
}
}
4 changes: 2 additions & 2 deletions packages/x-charts/src/BarChart/BarPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ const useAggregatedData = (): {

const data = stackingGroups.flatMap(({ ids: groupIds }, groupIndex) => {
return groupIds.flatMap((seriesId) => {
const xAxisId = series[seriesId].xAxisId ?? series[seriesId].xAxisKey ?? defaultXAxisId;
const yAxisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey ?? defaultYAxisId;
const xAxisId = series[seriesId].xAxisId ?? defaultXAxisId;
const yAxisId = series[seriesId].yAxisId ?? defaultYAxisId;

const xAxisConfig = xAxis[xAxisId];
const yAxisConfig = yAxis[yAxisId];
Expand Down
6 changes: 3 additions & 3 deletions packages/x-charts/src/BarChart/extremums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const getValueExtremum =

return Object.keys(series)
.filter((seriesId) => {
const yAxisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey;
const yAxisId = series[seriesId].yAxisId;
return yAxisId === axis.id || (isDefaultAxis && yAxisId === undefined);
})
.reduce(
Expand All @@ -38,8 +38,8 @@ const getValueExtremum =
const filter = getFilters?.({
currentAxisId: axis.id,
isDefaultAxis,
seriesXAxisId: series[seriesId].xAxisId ?? series[seriesId].xAxisKey,
seriesYAxisId: series[seriesId].yAxisId ?? series[seriesId].yAxisKey,
seriesXAxisId: series[seriesId].xAxisId,
seriesYAxisId: series[seriesId].yAxisId,
});

const [seriesMin, seriesMax] = stackedData?.reduce(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ function ChartsOnAxisClickHandler(props: ChartsOnAxisClickHandlerProps) {
series[seriesType]?.seriesOrder.forEach((seriesId) => {
const seriesItem = series[seriesType]!.series[seriesId];

const providedXAxisId = seriesItem.xAxisId ?? seriesItem.xAxisKey;
const providedYAxisId = seriesItem.yAxisId ?? seriesItem.yAxisKey;
const providedXAxisId = seriesItem.xAxisId;
const providedYAxisId = seriesItem.yAxisId;

const axisKey = isXaxis ? providedXAxisId : providedYAxisId;
if (axisKey === undefined || axisKey === USED_AXIS_ID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ function ChartsAxisTooltipContent(props: {
series[seriesType]!.seriesOrder.forEach((seriesId) => {
const item = series[seriesType]!.series[seriesId];

const providedXAxisId = item.xAxisId ?? item.xAxisKey;
const providedYAxisId = item.yAxisId ?? item.yAxisKey;
const providedXAxisId = item.xAxisId;
const providedYAxisId = item.yAxisId;

const axisKey = isXaxis ? providedXAxisId : providedYAxisId;

Expand All @@ -87,8 +87,7 @@ function ChartsAxisTooltipContent(props: {

const xAxisId = providedXAxisId ?? xAxisIds[0];
const yAxisId = providedYAxisId ?? yAxisIds[0];
const zAxisId =
(seriesToAdd as any).zAxisId ?? (seriesToAdd as any).zAxisKey ?? zAxisIds[0];
const zAxisId = (seriesToAdd as any).zAxisId ?? zAxisIds[0];

const getColor =
colorProcessors[seriesType]?.(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ function ChartsItemTooltipContent<T extends ChartSeriesType>(
const { zAxis, zAxisIds } = React.useContext(ZAxisContext);
const colorProcessors = useColorProcessor();

const xAxisId = (series as any).xAxisId ?? (series as any).xAxisKey ?? xAxisIds[0];
const yAxisId = (series as any).yAxisId ?? (series as any).yAxisKey ?? yAxisIds[0];
const zAxisId = (series as any).zAxisId ?? (series as any).zAxisKey ?? zAxisIds[0];
const xAxisId = (series as any).xAxisId ?? xAxisIds[0];
const yAxisId = (series as any).yAxisId ?? yAxisIds[0];
const zAxisId = (series as any).zAxisId ?? zAxisIds[0];

const getColor =
colorProcessors[series.type]?.(
Expand Down
7 changes: 3 additions & 4 deletions packages/x-charts/src/ChartsTooltip/useAxisTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,16 @@ export function useAxisTooltip(): null | UseAxisTooltipReturnValue {
return seriesOfType.seriesOrder.map((seriesId) => {
const seriesToAdd = seriesOfType.series[seriesId]!;

const providedXAxisId = seriesToAdd.xAxisId ?? seriesToAdd.xAxisKey;
const providedYAxisId = seriesToAdd.yAxisId ?? seriesToAdd.yAxisKey;
const providedXAxisId = seriesToAdd.xAxisId;
const providedYAxisId = seriesToAdd.yAxisId;

const axisKey = isXaxis ? providedXAxisId : providedYAxisId;

// Test if the series uses the default axis
if (axisKey === undefined || axisKey === USED_AXIS_ID) {
const xAxisId = providedXAxisId ?? xAxisIds[0];
const yAxisId = providedYAxisId ?? yAxisIds[0];
const zAxisId =
(seriesToAdd as any).zAxisId ?? (seriesToAdd as any).zAxisKey ?? zAxisIds[0];
const zAxisId = (seriesToAdd as any).zAxisId ?? zAxisIds[0];

const color =
colorProcessors[seriesType]?.(
Expand Down
6 changes: 3 additions & 3 deletions packages/x-charts/src/ChartsTooltip/useItemTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export function useItemTooltip<T extends ChartSeriesType>(): null | UseItemToolt
const { zAxis, zAxisIds } = React.useContext(ZAxisContext);
const colorProcessors = useColorProcessor();

const xAxisId = (series as any).xAxisId ?? (series as any).xAxisKey ?? xAxisIds[0];
const yAxisId = (series as any).yAxisId ?? (series as any).yAxisKey ?? yAxisIds[0];
const zAxisId = (series as any).zAxisId ?? (series as any).zAxisKey ?? zAxisIds[0];
const xAxisId = (series as any).xAxisId ?? xAxisIds[0];
const yAxisId = (series as any).yAxisId ?? yAxisIds[0];
const zAxisId = (series as any).zAxisId ?? zAxisIds[0];

if (!item || item.dataIndex === undefined) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ function ChartsVoronoiHandler(props: ChartsVoronoiHandlerProps) {
voronoiRef.current = {};
let points: number[] = [];
seriesOrder.forEach((seriesId) => {
const { data, xAxisId, yAxisId, xAxisKey, yAxisKey } = series[seriesId];
const { data, xAxisId, yAxisId } = series[seriesId];

const xScale = xAxis[xAxisId ?? xAxisKey ?? defaultXAxisId].scale;
const yScale = yAxis[yAxisId ?? yAxisKey ?? defaultYAxisId].scale;
const xScale = xAxis[xAxisId ?? defaultXAxisId].scale;
const yScale = yAxis[yAxisId ?? defaultYAxisId].scale;

const getXPosition = getValueToPositionMapper(xScale);
const getYPosition = getValueToPositionMapper(yScale);
Expand Down
9 changes: 2 additions & 7 deletions packages/x-charts/src/LineChart/AreaPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,14 @@ const useAggregatedData = () => {
.reverse() // Revert stacked area for a more pleasant animation
.map((seriesId) => {
const {
xAxisId: xAxisIdProp,
yAxisId: yAxisIdProp,
xAxisKey = defaultXAxisId,
yAxisKey = defaultYAxisId,
xAxisId = defaultXAxisId,
yAxisId = defaultYAxisId,
stackedData,
data,
connectNulls,
baseline,
} = series[seriesId];

const xAxisId = xAxisIdProp ?? xAxisKey;
const yAxisId = yAxisIdProp ?? yAxisKey;

const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
const yScale = yAxis[yAxisId].scale;
const xData = xAxis[xAxisId].data;
Expand Down
9 changes: 2 additions & 7 deletions packages/x-charts/src/LineChart/LineHighlightPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,13 @@ function LineHighlightPlot(props: LineHighlightPlotProps) {
{stackingGroups.flatMap(({ ids: groupIds }) => {
return groupIds.flatMap((seriesId) => {
const {
xAxisId: xAxisIdProp,
yAxisId: yAxisIdProp,
xAxisKey = defaultXAxisId,
yAxisKey = defaultYAxisId,
xAxisId = defaultXAxisId,
yAxisId = defaultYAxisId,
stackedData,
data,
disableHighlight,
} = series[seriesId];

const xAxisId = xAxisIdProp ?? xAxisKey;
const yAxisId = yAxisIdProp ?? yAxisKey;

if (disableHighlight || data[highlightedIndex] == null) {
return null;
}
Expand Down
9 changes: 2 additions & 7 deletions packages/x-charts/src/LineChart/LinePlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,13 @@ const useAggregatedData = () => {
return stackingGroups.flatMap(({ ids: groupIds }) => {
return groupIds.flatMap((seriesId) => {
const {
xAxisId: xAxisIdProp,
yAxisId: yAxisIdProp,
xAxisKey = defaultXAxisId,
yAxisKey = defaultYAxisId,
xAxisId = defaultXAxisId,
yAxisId = defaultYAxisId,
stackedData,
data,
connectNulls,
} = series[seriesId];

const xAxisId = xAxisIdProp ?? xAxisKey;
const yAxisId = yAxisIdProp ?? yAxisKey;

const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
const yScale = yAxis[yAxisId].scale;
const xData = xAxis[xAxisId].data;
Expand Down
9 changes: 2 additions & 7 deletions packages/x-charts/src/LineChart/MarkPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@ function MarkPlot(props: MarkPlotProps) {
{stackingGroups.flatMap(({ ids: groupIds }) => {
return groupIds.map((seriesId) => {
const {
xAxisId: xAxisIdProp,
yAxisId: yAxisIdProp,
xAxisKey = defaultXAxisId,
yAxisKey = defaultYAxisId,
xAxisId = defaultXAxisId,
yAxisId = defaultYAxisId,
stackedData,
data,
showMark = true,
Expand All @@ -106,9 +104,6 @@ function MarkPlot(props: MarkPlotProps) {
return null;
}

const xAxisId = xAxisIdProp ?? xAxisKey;
const yAxisId = yAxisIdProp ?? yAxisKey;

const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
const yScale = yAxis[yAxisId].scale;
const xData = xAxis[xAxisId].data;
Expand Down
6 changes: 3 additions & 3 deletions packages/x-charts/src/LineChart/extremums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const getExtremumY: ExtremumGetter<'line'> = (params) => {

return Object.keys(series)
.filter((seriesId) => {
const yAxisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey;
const yAxisId = series[seriesId].yAxisId;
return yAxisId === axis.id || (isDefaultAxis && yAxisId === undefined);
})
.reduce(
Expand All @@ -47,8 +47,8 @@ export const getExtremumY: ExtremumGetter<'line'> = (params) => {
const filter = getFilters?.({
currentAxisId: axis.id,
isDefaultAxis,
seriesXAxisId: series[seriesId].xAxisId ?? series[seriesId].xAxisKey,
seriesYAxisId: series[seriesId].yAxisId ?? series[seriesId].yAxisKey,
seriesXAxisId: series[seriesId].xAxisId,
seriesYAxisId: series[seriesId].yAxisId,
});

// Since this series is not used to display an area, we do not consider the base (the d[0]).
Expand Down
13 changes: 6 additions & 7 deletions packages/x-charts/src/ScatterChart/ScatterPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,16 @@ function ScatterPlot(props: ScatterPlotProps) {
return (
<React.Fragment>
{seriesOrder.map((seriesId) => {
const { id, xAxisKey, yAxisKey, zAxisKey, xAxisId, yAxisId, zAxisId, markerSize, color } =
series[seriesId];
const { id, xAxisId, yAxisId, zAxisId, markerSize, color } = series[seriesId];

const colorGetter = getColor(
series[seriesId],
xAxis[xAxisId ?? xAxisKey ?? defaultXAxisId],
yAxis[yAxisId ?? yAxisKey ?? defaultYAxisId],
zAxis[zAxisId ?? zAxisKey ?? defaultZAxisId],
xAxis[xAxisId ?? defaultXAxisId],
yAxis[yAxisId ?? defaultYAxisId],
zAxis[zAxisId ?? defaultZAxisId],
);
const xScale = xAxis[xAxisId ?? xAxisKey ?? defaultXAxisId].scale;
const yScale = yAxis[yAxisId ?? yAxisKey ?? defaultYAxisId].scale;
const xScale = xAxis[xAxisId ?? defaultXAxisId].scale;
const yScale = yAxis[yAxisId ?? defaultYAxisId].scale;
return (
<ScatterItems
key={id}
Expand Down
12 changes: 6 additions & 6 deletions packages/x-charts/src/ScatterChart/extremums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ export const getExtremumX: ExtremumGetter<'scatter'> = (params) => {

return Object.keys(series)
.filter((seriesId) => {
const axisId = series[seriesId].xAxisId ?? series[seriesId].xAxisKey;
const axisId = series[seriesId].xAxisId;
return axisId === axis.id || (axisId === undefined && isDefaultAxis);
})
.reduce(
(acc, seriesId) => {
const filter = getFilters?.({
currentAxisId: axis.id,
isDefaultAxis,
seriesXAxisId: series[seriesId].xAxisId ?? series[seriesId].xAxisKey,
seriesYAxisId: series[seriesId].yAxisId ?? series[seriesId].yAxisKey,
seriesXAxisId: series[seriesId].xAxisId,
seriesYAxisId: series[seriesId].yAxisId,
});

const seriesMinMax = series[seriesId].data?.reduce<ExtremumGetterResult>(
Expand All @@ -47,16 +47,16 @@ export const getExtremumY: ExtremumGetter<'scatter'> = (params) => {

return Object.keys(series)
.filter((seriesId) => {
const axisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey;
const axisId = series[seriesId].yAxisId;
return axisId === axis.id || (axisId === undefined && isDefaultAxis);
})
.reduce(
(acc, seriesId) => {
const filter = getFilters?.({
currentAxisId: axis.id,
isDefaultAxis,
seriesXAxisId: series[seriesId].xAxisId ?? series[seriesId].xAxisKey,
seriesYAxisId: series[seriesId].yAxisId ?? series[seriesId].yAxisKey,
seriesXAxisId: series[seriesId].xAxisId,
seriesYAxisId: series[seriesId].yAxisId,
});

const seriesMinMax = series[seriesId].data?.reduce<ExtremumGetterResult>(
Expand Down
10 changes: 0 additions & 10 deletions packages/x-charts/src/models/seriesType/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ export type CommonSeriesType<TValue> = {
export type CommonDefaultizedProps = 'id' | 'valueFormatter' | 'data';

export type CartesianSeriesType = {
/**
* The id of the x-axis used to render the series.
* @deprecated Use `xAxisId` instead
*/
xAxisKey?: string;
/**
* The id of the y-axis used to render the series.
* @deprecated Use `xAxisId` instead
*/
yAxisKey?: string;
/**
* The id of the x-axis used to render the series.
*/
Expand Down
5 changes: 0 additions & 5 deletions packages/x-charts/src/models/seriesType/scatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ export interface ScatterSeriesType extends CommonSeriesType<ScatterValueType>, C
* @default false
*/
disableHover?: boolean;
/**
* The id of the z-axis used to render the series.
* @deprecated Use `zAxisId` instead.
*/
zAxisKey?: string;
/**
* The id of the z-axis used to render the series.
*/
Expand Down
Loading