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] Cannot import BarElementPath from @mui/x-charts/BarChart/BarElement in a Vite project #11234

Closed
martin-mael opened this issue Nov 29, 2023 · 3 comments · Fixed by #11235
Labels
component: charts This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature

Comments

@martin-mael
Copy link

martin-mael commented Nov 29, 2023

Steps to reproduce

Link to live example: CodeSandbox

Steps:

  1. Import BarElementPath from @mui/x-charts/BarChart/BarElement

Current behavior

Vite fails to import the component.

Expected behavior

Vite should import the component, and it should be renderer correctly.

Context

I was trying to use a slot on my BarChart, in order to try to handle clicks on bars. I could use slotProps to add an onClick props, but I cannot seem to access the data (I need the series and the value clicked).

Your environment

npx @mui/envinfo

System:
OS: macOS 14.0
Binaries:
Node: 20.3.1 - ~/.nvm/versions/node/v20.3.1/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v20.3.1/bin/yarn
npm: 9.6.7 - ~/.nvm/versions/node/v20.3.1/bin/npm
Browsers:
Chrome: 119.0.6045.159
Edge: Not Found
Safari: 17.0
npmPackages:
@emotion/react: ^11.11.1 => 11.11.1
@emotion/styled: ^11.11.0 => 11.11.0
@mui/base: 5.0.0-beta.24
@mui/core-downloads-tracker: 5.14.18
@mui/icons-material: ^5.14.12 => 5.14.12
@mui/lab: ^5.0.0-alpha.152 => 5.0.0-alpha.152
@mui/material: ^5.14.18 => 5.14.18
@mui/private-theming: 5.14.18
@mui/styled-engine: 5.14.18
@mui/system: ^5.14.12 => 5.14.18
@mui/types: 7.2.9
@mui/utils: 5.14.18
@mui/x-charts: ^6.18.2 => 6.18.2
@mui/x-data-grid: 6.18.2
@mui/x-data-grid-pro: ^6.18.2 => 6.18.2
@mui/x-date-pickers: 6.16.2
@mui/x-date-pickers-pro: ^6.16.2 => 6.16.2
@mui/x-license-pro: 6.10.2
@types/react: ^18.2.37 => 18.2.37
react: ^18.2.0 => 18.2.0
react-dom: ^18.2.0 => 18.2.0
styled-components: ^5.3.11 => 5.3.11
typescript: ^5.2.2 => 5.2.2

Search keywords: charts barelementpath import
Order ID: 58926

@martin-mael martin-mael added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Nov 29, 2023
@martin-mael martin-mael changed the title Cannot import BarElementPath from @mui/x-charts/BarChart/BarElement in a Vite project [Charts] Cannot import BarElementPath from @mui/x-charts/BarChart/BarElement in a Vite project Nov 29, 2023
@alexfauquette
Copy link
Member

This issue has a perfect timing, I planned to work on cleaning exports today 👌

#11235

@alexfauquette alexfauquette added enhancement This is not a bug, nor a new feature 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 29, 2023
@martin-mael
Copy link
Author

Oh, perfect timing indeed, thanks a lot ! ❤️

@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 29, 2023

Also to be noted that @mui/x-charts/BarChart/BarElement is a forbidden import path since it's more than one level deep. This is a private module, the bundler failing is a side effect of it being private.

I guess Alexandre is going to make
BarElement public since the bar slot is exposed as public, with:

import { BarElement } from '@mui/x-charts/BarElement';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: charts This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants