一個比較正確的使用方法: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 sameparamsof'click'eventchartDblClick: It emits the sameparamsof'dblclick'eventchartMouseDown: It emits the sameparamsof'mousedown'eventchartMouseUp: It emits the sameparamsof'mouseup'eventchartMouseOver: It emits the sameparamsof'mouseover'eventchartMouseOut: It emits the sameparamsof'mouseout'eventchartGlobalOut: It emits the sameparamsof'globalout'eventchartContextMenu: It emits the sameparamsof'contextmenu'event (since v1.2.1)chartDataZoom: It emits the sameparamsof'dataZoom'event (thanks to averhaegen)
版權聲明:本文為博主原創文章,未經博主允許不得轉載。
