Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with libary and nodejs, browserless usage #116

Open
domoskanonos opened this issue Dec 17, 2021 · 4 comments
Open

Problem with libary and nodejs, browserless usage #116

domoskanonos opened this issue Dec 17, 2021 · 4 comments

Comments

@domoskanonos
Copy link

Hi, i try to use your library without browser (pure nodejs/typescript).
There ist a problem in usage discussed here:

SeanSobey/ChartjsNodeCanvas#47

I got this error:

return Object.prototype.isPrototypeOf.call(this.type.prototype, type.prototype);
^

TypeError: Cannot read property 'prototype' of undefined
at TypedRegistry.isForType (E:_dev\vhs\git\mmproject\node_modules\chart.js\dist\chart.js:5980:74)
at Registry._getRegistryForType (E:_dev\vhs\git\mmproject\node_modules\chart.js\dist\chart.js:6123:15)
at E:_dev\vhs\git\mmproject\node_modules\chart.js\dist\chart.js:6103:41
at Array.forEach ()
at Registry._each (E:_dev\vhs\git\mmproject\node_modules\chart.js\dist\chart.js:6102:15)
at Registry.add (E:_dev\vhs\git\mmproject\node_modules\chart.js\dist\chart.js:6060:10)
at Function.value [as register] (E:_dev\vhs\git\mmproject\node_modules\chart.js\dist\chart.js:7357:16)
at Object. (E:_dev\vhs\git\mmproject\lib\index.js:22:16)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)

my node dependencys:

"dependencies": {
"chartjs-chart-financial": "0.1.1",
"@babel/core": "7.16.0",
"@babel/preset-env": "7.16.4",
"@babel/preset-typescript": "7.16.0",
"@types/chart.js": "2.9.34",
"@types/jest": "27.0.3",
"@types/jsdom": "16.2.13",
"babel-jest": "27.4.4",
"canvas": "2.8.0",
"chart.js": "3.6.2",
"dotenv": "10.0.0",
"ftx-api": "1.0.19",
"jest": "27.4.3",
"jsdom": "19.0.0",
"npm-check-updates": "12.0.3",
"prettier": "2.5.1",
"trading-signals": "3.2.0",
"ts-jest": "27.1.0",
"ts-loader": "9.2.6",
"typescript": "4.5.4"
}

try to register candlestick Controller

import { OhlcElement, OhlcController, CandlestickElement, CandlestickController } from 'chartjs-chart-financial'
import Chart from 'chart.js/auto' // Easy way of importing everything

Chart.register(OhlcElement, OhlcController, CandlestickElement, CandlestickController)

please help me :-)

@domoskanonos
Copy link
Author

this lines cause the error (TypeError: Cannot read property 'prototype' of undefined) :

isForType(type) {
return Object.prototype.isPrototypeOf.call(this.type.prototype, type.prototype);
}

type is undefined

@SuchJitter
Copy link

I have the same error. Did you fix it?

@domoskanonos
Copy link
Author

no :-( , i change library to https://apexcharts.com/ this works better for me...

@SuchJitter
Copy link

I got it working, you have to use the fork from SeanSobey (https://github.com/SeanSobey/ChartjsNodeCanvas).
You have to require it in your file and also a date adapter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants