From f4dbb14f0515f1d48b539749e29f3b1daa16b950 Mon Sep 17 00:00:00 2001 From: Jack Date: Sun, 7 Jun 2020 02:30:49 +0100 Subject: [PATCH] fixed chart error point appearing on hover when they shouldnt have fixed wpm axis values overlapping --- public/js/script.js | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/public/js/script.js b/public/js/script.js index 737d59edb..edea745d0 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -1603,14 +1603,19 @@ let wpmOverTimeChart = new Chart(ctx, { var index = context.dataIndex; var value = context.dataset.data[index]; return value.y <= 0 ? 0 : 3 - } + }, + pointHoverRadius: function(context) { + var index = context.dataIndex; + var value = context.dataset.data[index]; + return value.y <= 0 ? 0 : 5 + }, }], }, options: { tooltips: { titleFontFamily: "Roboto Mono", bodyFontFamily: "Roboto Mono", - mode: 'x', + mode: 'index', intersect: false }, legend: { @@ -1621,15 +1626,17 @@ let wpmOverTimeChart = new Chart(ctx, { }, responsive: true, maintainAspectRatio: false, - hover: { - mode: 'x', - intersect: false - }, + // hover: { + // mode: 'x', + // intersect: false + // }, scales: { xAxes: [{ ticks: { - fontFamily: "Roboto Mono" + fontFamily: "Roboto Mono", + autoSkip: true, + autoSkipPadding: 20 }, display: true, scaleLabel: { @@ -1650,7 +1657,8 @@ let wpmOverTimeChart = new Chart(ctx, { fontFamily: 'Roboto Mono', beginAtZero: true, min: 0, - autoSkipPadding: 5 + autoSkip: true, + autoSkipPadding: 20 }, gridLines: { display:false @@ -1667,7 +1675,9 @@ let wpmOverTimeChart = new Chart(ctx, { ticks: { fontFamily: 'Roboto Mono', beginAtZero: true, - min: 0 + min: 0, + autoSkip: true, + autoSkipPadding: 20 }, gridLines: { display:false @@ -1685,7 +1695,9 @@ let wpmOverTimeChart = new Chart(ctx, { ticks: { precision:0, fontFamily: 'Roboto Mono', - beginAtZero: true + beginAtZero: true, + autoSkip: true, + autoSkipPadding: 20 }, gridLines: { display:true