xieziyu / ngx-echarts

An angular (ver >= 2.x) directive for ECharts (ver >= 3.x)
https://xieziyu.github.io/ngx-echarts/
MIT License
1.1k stars 195 forks source link

ngx-echarts@4.0.0-beta.0 / echarts-gl@1.1.1 issue #131

Closed ciukstar closed 6 years ago

ciukstar commented 6 years ago

After update from ngx-echarts@3.2.0 to ngx-echarts@4.0.0-beta.0 my chart { "xAxis3D": {...}, "yAxis3D": {...}, "zAxis3D": {...}, "grid3D": {...}, "series": { "type": "bar3D", ... } } that relies on echarts-gl@1.1.1 throws exception: "ERROR Error: Component series.bar3D not exists. Load it first.". It does work (no errors thrown) under ngx-echarts@3.2.0 with tsconfig.json: {..., "compilerOptions": {..., "paths": { "zrender": ["./node_modules/zrender/dist/zrender.min.js"], "echarts": ["./node_modules/echarts/dist/echarts.min.js"] },...}} and angular.json: {..., ... {..., "scripts": [..., "node_modules/echarts/dist/echarts.min.js", "node_modules/echarts-gl/dist/echarts-gl.min.js",...]}, ...}.

Please, provide some guidance on how to configure ngx-echarts@4.0.0-beta.0 with echarts-gl@1.1.1.

smnbbrv commented 6 years ago

did you try in your main.ts

import * as echarts from 'echarts';

(<any>window).echarts = echarts;

import 'echarts-gl/dist/echarts-gl.min.js';

instead of configuring this in angular.json?

ciukstar commented 6 years ago

Yes, adding

import * as echarts from 'echarts';
(<any>window).echarts = echarts;
import 'echarts-gl/dist/echarts-gl.min.js';

to main.ts and removing "node_modules/echarts/dist/echarts.min.js", "node_modules/echarts-gl/dist/echarts-gl.min.js" from {..., "scripts": [...]} in angular.json resolves the issue. Thank you!