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

Using Chart.js via Webpack does not work #938

Open
stefan-strobl-hr opened this issue Nov 11, 2024 · 0 comments
Open

Using Chart.js via Webpack does not work #938

stefan-strobl-hr opened this issue Nov 11, 2024 · 0 comments

Comments

@stefan-strobl-hr
Copy link

Describe the bug
When loading Chart.js via npm/webpack the following line is throwing an error.

 Unhandled exception rendering component: Cannot read properties of undefined (reading 'each')
      TypeError: Cannot read properties of undefined (reading 'each')
          at Object.get (http://localhost:5001/_content/Blazor.Bootstrap/blazor.bootstrap.js:1542:23)
          at Object.initialize (http://localhost:5001/_content/Blazor.Bootstrap/blazor.bootstrap.js:1551:44)
          at http://localhost:5001/_framework/blazor.webassembly.js:1:2878

To Reproduce
Steps to reproduce the behavior:

  1. Change from CDN URL to local webpack JS
  2. Load Chart:
import Chart from 'chart.js/auto';
window.Chart = Chart;
import { color } from 'chart.js/helpers';

Expected behavior
I would expect that the webpack version works the same as the CDN version.

Versions (please complete the following information):

  • .NET Version: .NET 8
  • BlazorBootstrap: 3.1.1
  • Blazor WebAssembly: 8.0.8
  • Chart.js: 4.4.6 (but also tried cdn referenced 4.0.1)

Sample code

# webpack.js
import Chart from 'chart.js/auto';
window.Chart = Chart;
import { color } from 'chart.js/helpers';

Maybe I'm missing something, maybe it's a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant