fix bug
This commit is contained in:
@ -4,7 +4,8 @@ import { DatePipe, _HttpClient } from '@delon/theme';
|
||||
import { differenceInCalendarDays } from 'date-fns';
|
||||
import { DataService } from '../../../services/data.service';
|
||||
import { Chart } from '@antv/g2';
|
||||
import { BusitableCurveComponent } from './curve2/curve.component';
|
||||
import { BusitablePillarComponent } from './pillar/pillar.component';
|
||||
import { BusitableCurveComponent } from './curve/curve.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-datatable-busiindex',
|
||||
@ -16,6 +17,7 @@ import { BusitableCurveComponent } from './curve2/curve.component';
|
||||
export class DatatableBusiindexComponent implements OnInit {
|
||||
@ViewChild('st') private readonly st!: STComponent;
|
||||
@ViewChild('curve') private readonly curve!: BusitableCurveComponent;
|
||||
@ViewChild('pillar') private readonly pillar!: BusitablePillarComponent;
|
||||
type = 1;
|
||||
mode = 'year';
|
||||
date: any = null;
|
||||
@ -26,9 +28,8 @@ export class DatatableBusiindexComponent implements OnInit {
|
||||
timeNext: any = ['2022-01-01 00:00:00']
|
||||
dateFormat = 'yyyy-MM-dd';
|
||||
today = new Date();
|
||||
chainRatio: any = []
|
||||
chartData: any = {}
|
||||
el: any;
|
||||
flag = false;
|
||||
|
||||
columns: STColumn[] = [
|
||||
{ title: '运营主体', index: 'networkTransporterName', className: 'text-center' },
|
||||
@ -80,12 +81,11 @@ export class DatatableBusiindexComponent implements OnInit {
|
||||
};
|
||||
this.service.request(this.service.$api_performanceReportHistogram, params).subscribe(res => {
|
||||
if (res) {
|
||||
this.chainRatio = res.chainRatio
|
||||
this.chartData = res
|
||||
setTimeout(() => {
|
||||
this.ngZone.runOutsideAngular(() => this.init(this.el));
|
||||
}, 1000);
|
||||
|
||||
if(this.flag) {
|
||||
this.pillar.reRender()
|
||||
this.curve.reRender()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -124,6 +124,8 @@ export class DatatableBusiindexComponent implements OnInit {
|
||||
} else if(this.mode === 'month') {
|
||||
this.timeNext = [this.datePipe.transform(this.dateNext, 'yyyy-MM') + '-01 00:00:00']
|
||||
}
|
||||
this.flag = true
|
||||
this.initData()
|
||||
}
|
||||
disabledDate = (current: Date): boolean =>
|
||||
// Can not select days before today and today
|
||||
@ -131,38 +133,4 @@ export class DatatableBusiindexComponent implements OnInit {
|
||||
exportFun(){
|
||||
|
||||
}
|
||||
|
||||
render(el: ElementRef<HTMLDivElement>): void {
|
||||
this.el = el.nativeElement
|
||||
|
||||
}
|
||||
|
||||
private init(el: HTMLElement): void {
|
||||
const chart = new Chart({
|
||||
container: el,
|
||||
autoFit: true,
|
||||
height: 500,
|
||||
});
|
||||
|
||||
chart.data(this.chainRatio);
|
||||
chart.scale({
|
||||
year: {
|
||||
range: [0, 1],
|
||||
},
|
||||
value: {
|
||||
min: 0,
|
||||
nice: true,
|
||||
},
|
||||
});
|
||||
|
||||
chart.tooltip({
|
||||
showCrosshairs: true, // 展示 Tooltip 辅助线
|
||||
shared: true,
|
||||
});
|
||||
|
||||
chart.line().position('time*value').label('value');
|
||||
chart.point().position('time*value');
|
||||
|
||||
chart.render();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user