You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

31 lines
672 B

import { AfterViewInit, Directive, ElementRef, Input } from '@angular/core';
import { ECharts, init } from 'echarts';
@Directive({
selector: '[echarts]'
})
export class EchartsDirective implements AfterViewInit {
constructor(
private _elementRef: ElementRef
) { }
ngAfterViewInit(): void {
this._echarts = init(this._elementRef.nativeElement);
if (this._options) {
this._echarts.setOption(this._options);
}
}
@Input()
public set echarts(options: any) {
if (this._options = options) {
if (this._echarts) {
this._echarts.setOption(options);
}
}
}
private _echarts: ECharts;
private _options: any;
}