primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Chart is not defined error

Open murathazer opened this issue 10 years ago • 20 comments

when we try to use doughnutChart component following error occurs;

angular2.dev.js:23730 ReferenceError: Chart is not defined
    at DoughnutChart.initChart (http://localhost:8080/node_modules/primeng/components/chart/doughnutchart/doughnutchart.js:91:30)
    at DoughnutChart.ngAfterViewInit (http://localhost:8080/node_modules/primeng/components/chart/doughnutchart/doughnutchart.js:62:14)
    at AbstractChangeDetector.ChangeDetector_FrontPageComponent_0.afterViewLifecycleCallbacksInternal (viewFactory_FrontPageComponent:119:82)
    at AbstractChangeDetector.afterViewLifecycleCallbacks (http://localhost:8080/node_modules/angular2/bundles/angular2.dev.js:9924:12)
"angular2": "2.0.0-beta.11",
"primeng": "^0.8.1",
"primeui": "^4.1.5"

murathazer avatar Mar 21 '16 10:03 murathazer

Welcome to PrimeNG, you also need to add charts.js to your page.

cagataycivici avatar Mar 21 '16 16:03 cagataycivici

I've got the same Problem. chart.js implemented before angular-chartjs.

Chart is not defined. Error occurs within my .html.

Faigjaz avatar Jun 14 '16 06:06 Faigjaz

@cagataycivici Could you please give a working example of chart using primeng ? and from where we have to add chart.js ?

abbas-innotical avatar Jun 23 '16 06:06 abbas-innotical

@abbas-innotical Could you please give a working example of chart using primeng ? and from where we have to add chart.js ?

leexiaozheng avatar Sep 14 '16 08:09 leexiaozheng

I would also like to see a working example of chart using primeng in order to see how to add it.

mornir avatar Oct 15 '16 17:10 mornir

Adding:

  <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.3/Chart.bundle.min.js"></script>

To my index.html page, resolved this issue for me.

JakeSummers avatar Oct 29 '16 21:10 JakeSummers

Y'know, the fact you have to import Chart.js isn't really mentioned on the showcase...

bomberblue07 avatar Dec 16 '16 00:12 bomberblue07

wow thank you , I would never have found this out.

dyrleif avatar Jan 24 '17 21:01 dyrleif

Hi! I am working with angular (v2+) in Typescript, I added:

npm install --save chart.js
npm install --save-dev @types/chart.js

But still couldn't work with a simple: import { Chart } from 'chart.js'; I have an issue. It seems chart.js is not typescript friendly..

merlosy avatar Mar 09 '17 14:03 merlosy

is there a way to load via angular cli? kinda sucks putting

Owner


Other Repo Issues