//doughnut let normal = 10; let good = 25; let perfect = 65; Chart.pluginService.register({ beforeDraw: function(chart) { var width = chart.chart.width, height = chart.chart.height, ctx = chart.chart.ctx; ctx.restore(); var fontSize = (height / 214).toFixed(2); ctx.font = fontSize + "em sans-serif"; ctx.textBaseline = "middle"; var text = perfect+"% отлично", textX = Math.round((width - ctx.measureText(text).width) / 2), textY = height / 2; ctx.fillText(text, textX, textY); ctx.save(); } }); var ctxD = document.getElementById("doughnutChart").getContext('2d'); var myLineChart = new Chart(ctxD, { type: 'doughnut', data: { labels: ["Нормально", "Хорошо", "Отлично"], datasets: [{ data: [normal, good, perfect], backgroundColor: ["#f8e729", "#0081EB", "#48DE20"], hoverBackgroundColor: [ "#f8e729","#0889f0", "#48DE39"] }] }, options: { responsive: true, legend: { display: false }, } });