Skip to content

[charts][LineChart] inconsistent behavior between yAxis scaleType "log" and "linear" for null values in the series #15322

@dandrei

Description

@dandrei

Steps to reproduce

Link to live example: https://codesandbox.io/p/sandbox/mui-x-linechart-6xplmw

Steps:

  1. Visit the live example, which contains the same series visualized in two ways: with yAxis scaleType set to "log" and to "linear"
  2. The series contains a null, which should be interpreted as simply "showing nothing", as per this comment.
  3. Observe the differences between the two charts.

Current behavior

The "linear" scale correctly shows an interrupted line where the value is missing.
The "log" scale isn't rendered at all.

Expected behavior

The "log" scale should mirror the behavior of the "linear" scale, namely treating null by not showing that specific data point, as opposed to not rendering the line at all.

Context

In the production use case, I am trying to display time series data (monthly measurements) that can have gaps in it (months with no measurements).

The user is free to choose whether they want to view the data on a linear scale or a logarithmic one.

While the linear scale always renders correctly, the logarithmic scale is not rendered at all for datasets with missing data points (months with null values). Ideally, the behavior would be identical for null values no matter the scale type.

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

System:
OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
Binaries:
Node: 20.18.0 - ~/.nvm/versions/node/v20.18.0/bin/node
npm: 10.8.2 - ~/.nvm/versions/node/v20.18.0/bin/npm
pnpm: Not Found
Browsers:
Chrome: Not Found
npmPackages:
@emotion/react: 11.13.3 => 11.13.3
@emotion/styled: 11.13.0 => 11.13.0
@mui/core-downloads-tracker: 6.1.6
@mui/icons-material: 6.1.6 => 6.1.6
@mui/material: 6.1.6 => 6.1.6
@mui/material-nextjs: 6.1.6 => 6.1.6
@mui/private-theming: 6.1.6
@mui/styled-engine: 6.1.6
@mui/styles: 6.1.6 => 6.1.6
@mui/system: 6.1.6
@mui/types: 7.2.19
@mui/utils: 6.1.6
@mui/x-charts: 7.22.1 => 7.22.1
@mui/x-charts-vendor: 7.20.0
@mui/x-data-grid: 7.22.1 => 7.22.1
@mui/x-internals: 7.21.0
@types/react: 18.3.11
react: next => 18.3.1
react-dom: next => 18.3.1
typescript: 5.6.3 => 5.6.3


</details>



**Search keywords**: LineChart error when yAxis scaleType is log

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: chartsChanges related to the charts.type: bugIt doesn't behave as expected.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions