浏览 126
分享
LineChartA line chart or line graph is a type of chart which displays information as a series of data points called 'markers' connected by straight line segments.
export class LineChartDemo {
data: any;
constructor(private messageService: MessageService) {
this.data = {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [
{
label: 'First Dataset',
data: [65, 59, 80, 81, 56, 55, 40],
fill: false,
borderColor: '#4bc0c0'
},
{
label: 'Second Dataset',
data: [28, 48, 40, 19, 86, 27, 90],
fill: false,
borderColor: '#565656'
}
]
}
}
selectData(event) {
this.messageService.add({severity: 'info', summary: 'Data Selected', 'detail': this.data.datasets[event.element._datasetIndex].data[event.element._index]});
}
}
linechartdemo.html
<p-toast [style]="{marginTop: '80px'}"></p-toast>
<p-chart type="line" [data]="data" (onDataSelect)="selectData($event)"></p-chart>
评论列表