Angular2或Angular4使用echarts , ngx-echarts的方法


一個比較正確的使用方法:https://github.com/xieziyu/ngx-echarts

1、

 

npm install echarts --save

npm install ngx-echarts --save

如果網速差,可以使用淘寶鏡像

 

2、項目中.angular-cli.json 中添加echarts

 

{
  "scripts": [ // ... // add this: "../node_modules/echarts/dist/echarts.min.js" // or echarts.js for debug purpose ], }

 

3、在module 中調用

 

import { AngularEchartsModule } from 'ngx-echarts'; @NgModule({ imports: [ ..., AngularEchartsModule ], ... }) export class AppModule { }

 

4、html中

 

<div echarts [options]="chartOption" class="demo-chart"></div>

 

5、chartOption就是option

 

6、事件方法

 

  • chartClick: It emits the same params of 'click' event
  • chartDblClick: It emits the same params of 'dblclick' event
  • chartMouseDown: It emits the same params of 'mousedown' event
  • chartMouseUp: It emits the same params of 'mouseup' event
  • chartMouseOver: It emits the same params of 'mouseover' event
  • chartMouseOut: It emits the same params of 'mouseout' event
  • chartGlobalOut: It emits the same params of 'globalout' event
  • chartContextMenu: It emits the same params of 'contextmenu' event (since v1.2.1)
  • chartDataZoom: It emits the same params of 'dataZoom' event (thanks to averhaegen)

 

 
        
版權聲明:本文為博主原創文章,未經博主允許不得轉載。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM