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] It's not possible to import DefaultChartsAxisContent #11136

Closed
micmcg opened this issue Nov 22, 2023 · 3 comments · Fixed by #11235
Closed

[charts] It's not possible to import DefaultChartsAxisContent #11136

micmcg opened this issue Nov 22, 2023 · 3 comments · Fixed by #11235
Labels
bug 🐛 Something doesn't work component: charts This is the name of the generic UI component, not the React module!

Comments

@micmcg
Copy link

micmcg commented Nov 22, 2023

Steps to reproduce

Link to live example: https://codesandbox.io/p/sandbox/pensive-feather-lyg7vg?file=%2Fsrc%2FDemo.tsx

Steps:

  1. import { DefaultChartsAxisContent } from "@mui/x-charts/ChartsTooltip/ChartsAxisTooltipContent"
  2. axisContent: props => <DefaultChartsAxisContent {...props}/>
  3. Get error ModuleNotFoundError: Could not find module in path: '@mui/x-charts/constants' relative to '/node_modules/@mui/x-charts/hooks/useChartDimensions.js'

Current behavior

Error is thrown

Expected behavior

Component should be able to be imported and used

Context

I'm trying to create a custom axisContent component that changes some of the props then calls DefaultChartsAxisContent, in order to bypass the current limitation that both the x-axis tick labels and the tooltip use the same valueFormatter - https://discord.com/channels/1131323012554174485/1131329761952682114/1176399032764092486

Related: #10928

Your environment

npx @mui/envinfo
System:
    OS: macOS 13.4.1
  Binaries:
    Node: 18.17.0 - ~/.nvm/versions/node/v18.17.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.17.0/bin/yarn
    npm: 9.6.7 - ~/.nvm/versions/node/v18.17.0/bin/npm
  Browsers:
    Chrome: 119.0.6045.159
    Edge: Not Found
    Safari: 16.5.2
  npmPackages:
    @emotion/react: ^11.4.1 => 11.4.1
    @emotion/styled: ^11.3.0 => 11.3.0
    @mui/base: ^5.0.0-alpha.91 => 5.0.0-alpha.91
    @mui/core-downloads-tracker:  5.14.2
    @mui/icons-material: ^5.11.11 => 5.11.16
    @mui/lab: 5.0.0-alpha.75 => 5.0.0-alpha.75
    @mui/material: ^5.13.6 => 5.14.2
    @mui/private-theming:  5.13.7
    @mui/styled-engine:  5.13.2
    @mui/system: ^5.13.6 => 5.14.1
    @mui/types:  7.1.5
    @mui/utils:  5.9.1
    @mui/x-charts: ^6.18.1 => 6.18.1
    @mui/x-data-grid: 5.6.0 => 5.6.0
    @mui/x-data-grid-pro: ^6.18.0 => 6.18.0
    @mui/x-date-pickers:  6.10.2
    @mui/x-date-pickers-pro: ^6.9.0 => 6.10.2
    @mui/x-license-pro:  6.10.2
    @types/react: ^17.0.42 => 17.0.42
    react: ^17.0.2 => 17.0.2
    react-dom: ^17.0.2 => 17.0.2
    typescript: ^5.1.6 => 5.1.6

Search keywords: Charts Axis Tooltip

@micmcg micmcg added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Nov 22, 2023
@LukasTy
Copy link
Member

LukasTy commented Nov 22, 2023

Hello @micmcg
The behavior is expected, we do not support 3rd-level imports.
In this case, I think it's up to the Charts team to decide if the relevant component will end up being exported. 🤔

As a temporary workaround if you really need this behavior, consider patching the package. You only need to add an export * from './ChartsAxisTooltipContent'; in the /ChartsTooltip/index.js file. 😉

@LukasTy LukasTy added component: charts This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 22, 2023
@LukasTy LukasTy changed the title Charts: It's not possible to import DefaultChartsAxisContent [charts] It's not possible to import DefaultChartsAxisContent Nov 22, 2023
@micmcg
Copy link
Author

micmcg commented Nov 22, 2023

Is it possible to change this to a request to make the default Slot components available for import then?

@LukasTy
Copy link
Member

LukasTy commented Nov 23, 2023

Is it possible to change this to a request to make the default Slot components available for import then?

That seems like a perfectly reasonable request. 👍
We'll evaluate other options and decide on the best approach. 😉

@DanailH DanailH added the bug 🐛 Something doesn't work label Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: charts This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants