fix bug
This commit is contained in:
@ -0,0 +1,74 @@
|
||||
import { Component, ElementRef, Input, NgZone, OnInit, ViewChild } from '@angular/core';
|
||||
import { G2MiniAreaClickItem } from '@delon/chart/mini-area';
|
||||
import DataSet from '@antv/data-set';
|
||||
import { Chart } from '@antv/g2';
|
||||
import { DataService } from 'src/app/routes/datatable/services/data.service';
|
||||
@Component({
|
||||
selector: 'app-busitable-curve',
|
||||
templateUrl: './curve.component.html',
|
||||
styleUrls: ['./curve.component.less']
|
||||
})
|
||||
export class busitableCurveComponent implements OnInit {
|
||||
@Input() chartData: any = {}
|
||||
constructor(private service: DataService, private ngZone: NgZone) {
|
||||
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
handleClick(data: G2MiniAreaClickItem): void {
|
||||
this.service.msgSrv.info(`${data.item.x} - ${data.item.y}`);
|
||||
}
|
||||
|
||||
render(el: ElementRef<HTMLDivElement>): void {
|
||||
this.ngZone.runOutsideAngular(() => this.init(el.nativeElement));
|
||||
}
|
||||
private init(el: HTMLElement): void {
|
||||
const data = [
|
||||
{ month: '01月', value: 3 },
|
||||
{ month: '02月', value: 4 },
|
||||
{ month: '03月', value: 3.5 },
|
||||
{ month: '04月', value: 5 },
|
||||
{ month: '05月', value: 4.9 },
|
||||
{ month: '06月', value: 6 },
|
||||
{ month: '07月', value: 7 },
|
||||
{ month: '08月', value: 9 },
|
||||
{ month: '09月', value: 13 },
|
||||
{ month: '10月', value: 13 },
|
||||
{ month: '11月', value: 13 },
|
||||
{ month: '12月', value: 13 },
|
||||
];
|
||||
const chart = new Chart({
|
||||
container: el,
|
||||
autoFit: true,
|
||||
height: 500,
|
||||
});
|
||||
|
||||
chart.data(data);
|
||||
chart.scale({
|
||||
month: {
|
||||
range: [0, 1],
|
||||
},
|
||||
value: {
|
||||
min: 0,
|
||||
nice: true,
|
||||
},
|
||||
});
|
||||
|
||||
chart.tooltip({
|
||||
showCrosshairs: true, // 展示 Tooltip 辅助线
|
||||
shared: true,
|
||||
});
|
||||
|
||||
chart.line().position('month*value').label('value');
|
||||
//chart.point().position('month*value');
|
||||
|
||||
chart.render();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user