Pass options correctly to chart.js on articles#stats (#17435)

Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
This commit is contained in:
Takuya N 2022-05-04 17:42:55 +09:00 committed by GitHub
parent f4e0944bb0
commit 275cdadb60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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(