Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
N

ngx-echarts

> 前端框架
Open source

An angular (ver >= 2.x) directive for ECharts (ver >= 3.x)

1.2K stars0 likes0 views
WebsiteGitHub

About

An angular (ver >= 2.x) directive for ECharts (ver >= 3.x)

Table of contents

  • Getting Started
  • Latest Update
  • Installation
    • Upgrade from v4.x
  • Usage
    • Standalone
    • NgModule
    • Directive
  • API
    • Directive
    • ECharts API
    • ECharts Instance
    • ECharts Extensions
    • Service
  • Events
  • Custom Build
    • Treeshaking Custom Build
    • Legacy Custom Build
  • Custom Locale
  • Demo

Getting Started

ngx-echarts is an Angular (ver >= 2.x) directive for ECharts (ver >= 3.x).

Latest version @npm:

  • v22.0.0 for Angular 22
  • v21.0.0 for Angular 21
  • v20.0.1 for Angular 20
  • v19.0.0 for Angular 19
  • v18.0.0 for Angular 18
  • v17.2.0 for Angular 17
  • v16.2.0 for Angular 16
  • v15.0.3 for Angular 15
  • v14.0.0 for Angular 14
  • v8.0.1 for Angular 13
  • v7.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:

…

Legacy Custom Build

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:

typescript
// 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:

typescript
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:

typescript
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:

typescript
// ... 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);
    }
}

Custom Locale

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).

typescript
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:

xml

Demo

You can clone this repo to your working copy and then launch the demo page in your local machine:

bash
npm install
npm run demo

# or
yarn install
yarn demo

The demo page server is listening on: http://localhost:4202

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptangularangular2echartsng2

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架