tsur / canvasjs

39 stars 40 forks source link

intToHexColorString #6

Open spidgorny opened 7 years ago

spidgorny commented 7 years ago

I get: ReferenceError: intToHexColorString is not defined[Learn More] canvasjs.js:8860:11 in version 1.8.1.

JustFly1984 commented 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.

watat83 commented 6 years ago

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:

N.B: This hack should work with other JS libraries that don't have TypeScript definition yet.

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.