Topic: Migrating charts to 7.2.0

Torroni pro asked 2 months ago

Expected behavior a chart component is initialized correctly.

Actual behavior Error initializing the chart

Resources (screenshots, code snippets etc.) I create a bar chart in this way: HTML:

<canvas id="bar-chart" data-mdb-chart-init></canvas>


var barChart = document.querySelector("#bar-chart");
var processingPerfChart = new mdb.Chart(barChart, { type: 'bar' });

When I load the html file locally in the browser, the chart is not initialized and the console shows the following error:

mdb.umd.min.js:39  Uncaught Error: "undefined" is not a registered controller.
    at Object._get (mdb.umd.min.js:39:61429)
    at Object.getController (mdb.umd.min.js:39:60493)
    at qd.buildOrUpdateControllers (mdb.umd.min.js:39:85223)
    at qd.update (mdb.umd.min.js:39:85984)
    at new qd (mdb.umd.min.js:39:82354)
    at Gp._chartConstructor (mdb.umd.min.js:39:171040)
    at new Gp (mdb.umd.min.js:39:168782)
    at mdb.umd.min.js:44:83240
    at Array.forEach (<anonymous>)
    at Object.advanced (mdb.umd.min.js:44:82964)

Kamila Pieńkowska staff answered 2 months ago

My answer form your thread about datatable is also valid here. You are doing double init here. Beside questions I've asked there can you tell me if you use any bundler or framework?

Torroni pro commented 2 months ago

no bundler, no framework, just plain vanilla javascript. I have removed the data-init from the canvas element and now everything works (also the datatables, without doing any changes). Maybe the migration guide could be updated to specify that the data-init attribute is not required when using the constructor. When I have read the sentence "To initialize component we are now using data attributes unified through all components and plugins" I thought the data-init attribute was mandatory. Thanks!

Kamila Pieńkowska staff commented 1 month ago

We will consider this. Thanks for sharing your experience.

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: MDB5 7.2.0
  • Device: laptop
  • Browser: Version 122.0.6261.129 (Official Build) (64-bit)
  • OS: Microsoft Windows 11 Pro
  • Provided sample code: No
  • Provided link: No