Skip to content

Commit

Permalink
[charts] Fix area with log scale (#13791)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette authored Jul 10, 2024
1 parent f4ff9f1 commit 0c98c78
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion packages/x-charts/src/LineChart/AreaPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ const useAggregatedData = () => {
}>()
.x((d) => xScale(d.x))
.defined((_, i) => connectNulls || data[i] != null)
.y0((d) => d.y && yScale(d.y[0])!)
.y0((d) => {
const value = d.y && yScale(d.y[0])!;
if (Number.isNaN(value)) {
return yScale.range()[0];
}
return value;
})
.y1((d) => d.y && yScale(d.y[1])!);

const curve = getCurveFactory(series[seriesId].curve);
Expand Down
3 changes: 2 additions & 1 deletion packages/x-charts/src/LineChart/extremums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export const getExtremumY: ExtremumGetter<'line'> = (params) => {
const { area, stackedData } = series[seriesId];
const isArea = area !== undefined;

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]).
const getValues: GetValuesTypes =
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]).

const seriesExtremums = getSeriesExtremums(getValues, stackedData);

Expand Down

0 comments on commit 0c98c78

Please sign in to comment.