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] Fix area with log scale #13791

Merged
merged 1 commit into from
Jul 10, 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
[charts] Fix area with log scale
  • Loading branch information
alexfauquette committed Jul 10, 2024
commit 52fba670c42ca5b1319a3b653b328f4aad68ead7
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
Loading