我正在使用ng2-chart在Angular 8中创建图表。
我只有一个问题:我无法在图表上设置注释。
图表的x轴是日期(以字符串形式),格式如下:yyyy-MM-dd HH:mm:ss.z
注释配置如下:
let annotation = {
drawTime: 'afterDraw', // tried default afterDatasetsDraw without success
type: 'line',
mode: 'vertical',
scaleID: 'x-axis-0',
value: deviceInjectionTime, // This value is also a `yyyy-MM-dd HH:mm:ss.z` string date
borderColor: 'orange',
borderWidth: 2,
label: {
enabled: true,
fontColor: 'orange',
content: 'DEVICE'
}
};
this.lineChartOptionsITAG.annotation.annotations.push(annotation);
我的图表选项是:
public lineChartOptionsITAG: (ChartOptions & { annotation: any }) = {
responsive: false,
scales: {
// We use this empty structure as a placeholder for dynamic theming.
xAxes: [{}],
yAxes: [
{
id: 'y-axis-0',
position: 'left',
gridLines: {
color: 'rgba(255,0,0,0.3)',
},
},
]
},
annotation: {
annotations: [
],
},
};
当前结果如下:
我正在尝试的可能吗?如果是这样,我在做什么错了?