javascript - Getting 'Chart is not defined' error when using chart.js in Meteor -


i using official chart.js atmosphere package in meteor application. i've tried running example chart see if can pull getting issue saying "referenceerror: chart not defined"

here steps took installing atmosphere package , running code produce chart.

  1. installed package meteor add chart:chart
  2. in html added canvas tag calling chart it's informaiton
  3. in js added function creates chart along relevant information

when go page however, empty 400x400 image canvas there no content there chart supposed be. assist me in figuring out step i'm missing in order chart appear?

html

<template name="home_page"> <canvas id="mychart" width="400" height="400"></canvas> </template> 

js

import './home-page.html';   template.home_page.onrendered(function homepageonrendered() { var ctx = document.getelementbyid("mychart").getcontext("2d");     var mychart = new chart(ctx, {         type: 'bar',         data: {             labels: ["red", "blue", "yellow", "green", "purple", "orange"],             datasets: [{                 label: '# of votes',                 data: [12, 19, 3, 5, 2, 3],                 backgroundcolor: [                     'rgba(255, 99, 132, 0.2)',                     'rgba(54, 162, 235, 0.2)',                     'rgba(255, 206, 86, 0.2)',                     'rgba(75, 192, 192, 0.2)',                     'rgba(153, 102, 255, 0.2)',                     'rgba(255, 159, 64, 0.2)'                 ],                 bordercolor: [                     'rgba(255,99,132,1)',                     'rgba(54, 162, 235, 1)',                     'rgba(255, 206, 86, 1)',                     'rgba(75, 192, 192, 1)',                     'rgba(153, 102, 255, 1)',                     'rgba(255, 159, 64, 1)'                 ],                 borderwidth: 1             }]         },         options: {             scales: {                 yaxes: [{                     ticks: {                         beginatzero:true                     }                 }]             }         }     }); }); 

ok forgot add

import chart 'chart.js'  

in top of js file. fixed it.


Comments