使用chart.scales [“ x轴-0”]。top获取红线的长度(以像素为单位。)>
var ctx = document.getElementById('myChart').getContext('2d');
var chart = new Chart(ctx, {
// The type of chart we want to create
type: 'line',
// The data for our dataset
data: {
...
datasets: [{
...
}]
},
// Configuration options go here
options: {}
});