我正在使用 angular2-highcharts 折线图来显示每周的访问者。我使用模拟数据在图表中创建点。我想要实现的是,当用户单击某个点时,他/她可以输入诸如“平安夜”之类的内容,然后在该点显示注释。
import { Component, OnInit } from '@angular/core';
import { Data } from '../data';
import { DataService } from '../data.service';
import { ChartOptions, Options } from 'highcharts';
@Component({
selector: 'app-highcharts',
templateUrl: './highcharts.component.html',
styleUrls: ['./highcharts.component.css'],
template: `
<div class="container">
<div class="chart">
<chart [options]="options">
<series (click)="click($event)">
</series>
</chart>
<p>{{serieName}} is geselecteerd<p>
</div>
`,
})
export class HighchartsComponent implements OnInit {
title = "Highcharts PoC"
public options: Options;
constructor(private dataService: DataService) {
this.options = {
title: { text: 'Visitors per week' },
chart: { zoomType: 'x' },
yAxis: {
title: {
text: "Visitors"
}
},
xAxis: {
title: {
text: "Week number"
}
},
plotOptions: {
series: {
cursor: 'pointer',
point: {
events: {
click: function () {
{
this.serieName = 'Appell';
return true
}
// alert('Christmas Eve');
// return true;
}
}
},
pointStart: 1 // Week number
}
},
series: [{
name: '2017',
data: dataService.getHighchartsData()
}
]
};
}
ngOnInit() {
}
}