-
Notifications
You must be signed in to change notification settings - Fork 359
Description
Describe the bug
The function registerThemes
, but also pretty much every other class/function, expects the echarts
object to be available in the global scope. At first I though this was only for lazily loaded modules, but I can reproduce it for the root component as well.
Stacktrace:
Uncaught ReferenceError: echarts is not defined
registerTheme covalent-echarts-base.mjs:4321
registerDefaultThemes covalent-echarts-base.mjs:4328
7958 covalent-echarts-base.mjs:4819
Webpack 13
covalent-echarts-base.mjs:4321:4
To Reproduce
Steps to reproduce the behavior:
- Clone and run this project: https://github.com/vhdirk/covalent-echarts-test
- Click the link on the page
- See error in console
Expected behavior
Echarts should just load. At this point, it is just not usable.
Desktop:
any
Smartphone:
any
Additional context
It should be possible to import the echarts library using import * as echarts from 'echarts';
. However, I think the echarts object should be a singleton, so it should be provided in a service (that is provededIn: 'root'
). I think the best option would be to clone what they did in: https://www.npmjs.com/package/ngx-echarts#treeshaking-custom-build
I think each covalent echarts submodule could register what it uses on the global 'echarts' object?