Open spidgorny opened 7 years ago
Same issue:
I tried to import your library as ES6:
import CanvasJS from 'canvasjs'
- eslint says that there is no default export in 'canvasjs'
I tried to import your library partitially:
import { Chart } from 'canvasjs/dist/canvasjs'
and get this runtime error in build.js file:
canvasjs.js:8860 Uncaught ReferenceError: intToHexColorString is not defined
Please, can you go through your repo with ESlint? there is hell of a lot errors and bloated dead code. Currently I can properly use your library only included in script, but it is no way to use it in react.
I am experiencing the same kind of error right now, but to answer your question about importing CanvasJS into ES6, the way I did inside my Angular 5 project was:
1. Load the javascript file into index.html. I made sure the file was located inside my assets/js/
folder
2. Declare CanvasJS in your .ts file: In your typescript file, where you want to import and use CanvasJS, simply add this line at the top (along with other imports statements): declare var CanvasJS:any;
3. Test that CanvasJS is loaded: Inside your constructor function, simply console.log(CanvasJS)
. If an object is returned, it means that CanvasJS was successfully loaded. If not, make sure you imported the file correctly inside your HTML file.
I am still researching about intToHexColorString
issue but I thought this would help someone out there.
I get:
ReferenceError: intToHexColorString is not defined[Learn More] canvasjs.js:8860:11
in version 1.8.1.