Skip to content

Commit c229948

Browse files
committed
feedback
1 parent 05468b4 commit c229948

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,11 @@ const useAggregatedData = (): {
138138
});
139139
const barOffset = groupIndex * (barWidth + offset);
140140

141-
const { stackedData } = series[seriesId];
141+
const { stackedData, data: currentSeriesData, layout } = series[seriesId];
142142

143-
return stackedData
144-
.map((values, dataIndex: number) => {
143+
return baseScaleConfig
144+
.data!.map((baseValue, dataIndex: number) => {
145+
const values = stackedData[dataIndex];
145146
const valueCoordinates = values.map((v) => (verticalLayout ? yScale(v)! : xScale(v)!));
146147

147148
const minValueCoord = Math.round(Math.min(...valueCoordinates));
@@ -152,19 +153,15 @@ const useAggregatedData = (): {
152153
const result = {
153154
seriesId,
154155
dataIndex,
155-
layout: series[seriesId].layout,
156-
x: verticalLayout
157-
? xScale(xAxis[xAxisId].data?.[dataIndex])! + barOffset
158-
: minValueCoord,
159-
y: verticalLayout
160-
? minValueCoord
161-
: yScale(yAxis[yAxisId].data?.[dataIndex])! + barOffset,
156+
layout,
157+
x: verticalLayout ? xScale(baseValue)! + barOffset : minValueCoord,
158+
y: verticalLayout ? minValueCoord : yScale(baseValue)! + barOffset,
162159
xOrigin: xScale(0)!,
163160
yOrigin: yScale(0)!,
164161
height: verticalLayout ? maxValueCoord - minValueCoord : barWidth,
165162
width: verticalLayout ? barWidth : maxValueCoord - minValueCoord,
166163
color: colorGetter(dataIndex),
167-
value: series[seriesId].data[dataIndex],
164+
value: currentSeriesData[dataIndex],
168165
maskId: `${chartId}_${stackId || seriesId}_${groupIndex}_${dataIndex}`,
169166
};
170167

packages/x-charts/src/LineChart/LinePlot.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import * as React from 'react';
33
import PropTypes from 'prop-types';
44
import { styled } from '@mui/material/styles';
5+
import { warnOnce } from '@mui/x-internals/warning';
56
import { line as d3Line } from '@mui/x-charts-vendor/d3-shape';
67
import {
78
LineElement,
@@ -98,8 +99,9 @@ const useAggregatedData = () => {
9899
);
99100
}
100101
if (xData.length < stackedData.length) {
101-
throw new Error(
102+
warnOnce(
102103
`MUI X: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`,
104+
'error',
103105
);
104106
}
105107
}

0 commit comments

Comments
 (0)