From 275cdadb60a3761d54ba303ba4848bec370d6ce7 Mon Sep 17 00:00:00 2001 From: Takuya N Date: Wed, 4 May 2022 17:42:55 +0900 Subject: [PATCH] Pass options correctly to chart.js on articles#stats (#17435) Signed-off-by: Takuya Noguchi --- app/javascript/analytics/dashboard.js | 34 +++++++++++++-------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/app/javascript/analytics/dashboard.js b/app/javascript/analytics/dashboard.js index 5428bf28e..32b1a7b34 100644 --- a/app/javascript/analytics/dashboard.js +++ b/app/javascript/analytics/dashboard.js @@ -45,15 +45,23 @@ function writeCards(data, timeRangeLabel) { } function drawChart({ id, showPoints = true, title, labels, datasets }) { - const chartOptions = showPoints - ? {} - : { - elements: { - point: { - radius: 0, - }, + const chartOptions = { + elements: { + point: { + // The default is 3: https://www.chartjs.org/docs/latest/configuration/elements.html#point-configuration + radius: showPoints ? 3 : 0, + }, + }, + scales: { + y: { + type: 'linear', + suggestedMin: 0, + ticks: { + precision: 0, }, - }; + }, + }, + }; const dataOptions = { plugins: { legend: { @@ -65,16 +73,6 @@ function drawChart({ id, showPoints = true, title, labels, datasets }) { display: true, text: title, }, - scales: { - y: { - type: 'linear', - suggestedMin: 0, - - ticks: { - precision: 0, - }, - }, - }, }; import('chart.js').then(