Skip to content

Commit 0c98c78

Browse files
[charts] Fix area with log scale (#13791)
1 parent f4ff9f1 commit 0c98c78

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,13 @@ const useAggregatedData = () => {
9191
}>()
9292
.x((d) => xScale(d.x))
9393
.defined((_, i) => connectNulls || data[i] != null)
94-
.y0((d) => d.y && yScale(d.y[0])!)
94+
.y0((d) => {
95+
const value = d.y && yScale(d.y[0])!;
96+
if (Number.isNaN(value)) {
97+
return yScale.range()[0];
98+
}
99+
return value;
100+
})
95101
.y1((d) => d.y && yScale(d.y[1])!);
96102

97103
const curve = getCurveFactory(series[seriesId].curve);

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ export const getExtremumY: ExtremumGetter<'line'> = (params) => {
4141
const { area, stackedData } = series[seriesId];
4242
const isArea = area !== undefined;
4343

44-
const getValues: GetValuesTypes = isArea ? (d) => d : (d) => [d[1], d[1]]; // Since this series is not used to display an area, we do not consider the base (the d[0]).
44+
const getValues: GetValuesTypes =
45+
isArea && axis.scaleType !== 'log' ? (d) => d : (d) => [d[1], d[1]]; // Since this series is not used to display an area, we do not consider the base (the d[0]).
4546

4647
const seriesExtremums = getSeriesExtremums(getValues, stackedData);
4748

0 commit comments

Comments
 (0)