This commit is contained in:
Lingzi
2022-04-02 18:02:29 +08:00
parent be8a1dafb9
commit 7933b1ad54
20 changed files with 126 additions and 48 deletions

View File

@ -0,0 +1 @@
<g2-custom delay="200" (render)="render($event)"></g2-custom>

View File

@ -0,0 +1,56 @@
import { Component, ElementRef, Input, NgZone, OnChanges, OnInit, SimpleChanges, ViewChild } from '@angular/core';
import { Chart } from '@antv/g2';
import { DataService } from 'src/app/routes/datatable/services/data.service';
@Component({
selector: 'app-busitable-pillar',
templateUrl: './pillar.component.html',
styleUrls: ['./pillar.component.less']
})
export class BusitablePillarComponent implements OnInit, OnChanges {
el: any;
@Input() chartData: any;
chart: any;
constructor(private service: DataService, private ngZone: NgZone) {
}
ngOnChanges(changes: SimpleChanges): void {
if (this.chartData) {
// setTimeout(()=>{
// this.chart.render(true)
// }, 1000)
}
}
ngOnInit(): void {
}
reRender() {
setTimeout(() => {
this.chart.data(this.chartData);
this.chart.render();
}, 500)
}
render(el: ElementRef<HTMLDivElement>): void {
this.el = el.nativeElement
this.ngZone.runOutsideAngular(() => this.init(this.el));
}
private init(el: HTMLElement): void {
this.chart = new Chart({
container: el,
autoFit: true,
height: 500,
});
this.chart.data(this.chartData);
this.chart.tooltip({
showMarkers: false,
});
this.chart.interval().position('time*number');
this.chart.render();
}
}