An angular (ver >= 2.x) directive for ECharts (ver >= 3.x)
An angular (ver >= 2.x) directive for ECharts (ver >= 3.x)
ngx-echarts is an Angular (ver >= 2.x) directive for ECharts (ver >= 3.x).
Latest version @npm:
v22.0.0 for Angular 22v21.0.0 for Angular 21v20.0.1 for Angular 20v19.0.0 for Angular 19v18.0.0 for Angular 18v17.2.0 for Angular 17v16.2.0 for Angular 16v15.0.3 for Angular 15v14.0.0 for Angular 14v8.0.1 for Angular 13v7.1.0 for Angular >= 11, = 10, = 6, Since version 5.0.1 ECharts supports Treeshaking with NPM.The app.modules.ts should look like this:
…Please refer to ECharts Documentation for more details.
If you want to produce a custom build of ECharts, prepare a file like custom-echarts.ts:
// custom-echarts.ts
export * from 'echarts/src/echarts';
import 'echarts/src/chart/line';
import 'echarts/src/chart/bar';
// component examples:
import 'echarts/src/component/tooltip';
import 'echarts/src/component/title';
import 'echarts/src/component/toolbox';And then inject it in your NgxEchartsModule:
import { NgxEchartsModule } from 'ngx-echarts';
import * as echarts from './custom-echarts';
@NgModule({
imports: [
NgxEchartsModule.forRoot({
echarts,
}),
],
})
export class AppModule {}And if you want to use the global echarts object, please import it from lib or src instead:
import * as echarts from 'echarts/lib/echarts';If you need to import theme files, remember to change the 'echarts' path to 'echarts/lib/echarts', for example:
// ... part of echarts/theme/dark.js:
function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['exports', 'echarts/lib/echarts'], factory);
} else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
// CommonJS
factory(exports, require('echarts/lib/echarts'));
} else {
// Browser globals
factory({}, root.echarts);
}
}You can change the chart locale registering a built-in locale (located in node_modules/echarts/lib/i18n/) or a custom locale object. To register a locale, you will need to change the module that echart is being imported (usually app.module.ts).
import {NgxEchartsModule} from "ngx-echarts";
import * as echarts from 'echarts/core';
import langCZ from 'echarts/lib/i18n/langCZ';
echarts.registerLocale("CZ", langCZ)
@NgModule({
imports: [NgxEchartsModule.forRoot({echarts})],
declarations: [],
providers: [],
bootstrap: [AppComponent]
})and in your HTML file use:
You can clone this repo to your working copy and then launch the demo page in your local machine:
npm install
npm run demo
# or
yarn install
yarn demoThe demo page server is listening on: http://localhost:4202
No open issues yet, or sync has not completed.