window.chartColors = { red: 'rgb(255, 99, 132)', orange: 'rgb(255, 159, 64)', yellow: 'rgb(255, 205, 86)', green: 'rgb(75, 192, 192)', blue: 'rgb(54, 162, 235)', purple: 'rgb(153, 102, 255)', grey: 'rgb(201, 203, 207)' }; var config = { type: 'line', data: { labels: ["0秒","10秒","20秒","30秒","40秒","50秒","60秒","70秒","80秒","90秒","100秒","110秒","120秒","130秒","140秒","150秒","160秒","170秒","180秒"], datasets: [{ label: '瞬时速度', backgroundColor: window.chartColors.orange, borderColor: window.chartColors.orange, data: [18,6,6,-6,12,12,24,30,12,18,24,18,30,6,0,6,12,0,12], fill: false, }] }, options: { responsive: true, title: { display: false, text: '打字速度曲线' }, tooltips: { mode: 'index', intersect: false, }, hover: { mode: 'nearest', intersect: true }, scales: { xAxes: [{ display: true, scaleLabel: { display: true, labelString: '时间' } }], yAxes: [{ display: true, scaleLabel: { display: true, labelString: '速度' } }] } } }; window.onload = function() { var ctx = document.getElementById('canvas').getContext('2d'); window.myLine = new Chart(ctx, config); };