Cant use Chart

noveltytech pro premium priority asked 3 years ago

*Expected behavior*use chart component*Actual behavior*Chart is not displayed*Resources (screenshots, code snippets etc.)*ERROR ReferenceError: Chart is not defined

html

.tsdatasets = [ { label: 'Traffic', data: [2112, 2343, 2545, 3423, 2365, 1985, 987], }, ];

labels = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];


Arkadiusz Idzikowski staff commented 3 years ago

@noveltytech Did you install chartjs library and add imports to the angular.json file?


noveltytech pro premium priority commented 3 years ago

Hello Arkadiusz,

I installed chartjs should I import in app.module or angular.json file? could you please provide me the code ?

THanks


Arkadiusz Idzikowski staff answered 3 years ago

@noveltytech In angular.json file you need to find an object named after your project and update the scripts array:

 "scripts": [
     "node_modules/chart.js/dist/chart.js"
 ]

You also need to import MdbChartModule in your app.module in order to use MdbChartDirective.


Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB Angular
  • MDB Version: MDB5 1.0.0
  • Device: mac
  • Browser: firefox
  • OS: big sur
  • Provided sample code: No
  • Provided link: No
Tags