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.
32 lines
672 B
32 lines
672 B
5 months ago
|
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;
|
||
|
}
|