remove default axeis labels

This commit is contained in:
vcoppe
2024-04-29 13:29:10 +02:00
parent 687c998678
commit 412852d1ff

View File

@@ -63,19 +63,21 @@
scales: { scales: {
x: { x: {
type: 'linear', type: 'linear',
title: { ticks: {
display: true, callback: function (value: number, index: number, ticks: { value: number }[]) {
text: `${$_('quantities.distance')} (${getDistanceUnits()})`, if (index === ticks.length - 1) {
padding: 0, return `${value.toFixed(1).replace(/\.0+$/, '')}`;
align: 'end' }
return `${value.toFixed(1).replace(/\.0+$/, '')} ${getDistanceUnits()}`;
}
} }
}, },
y: { y: {
type: 'linear', type: 'linear',
title: { ticks: {
display: true, callback: function (value: number) {
text: `${$_('quantities.elevation')} (${getElevationUnits()})`, return getElevationWithUnits(value, false);
padding: 0 }
} }
} }
}, },
@@ -196,7 +198,7 @@
}; };
} }
options.scales.yspeed['ticks'] = { options.scales.yspeed['ticks'] = {
callback: function (value) { callback: function (value: number) {
if ($settings.velocityUnits === 'speed') { if ($settings.velocityUnits === 'speed') {
return value; return value;
} else { } else {
@@ -317,8 +319,6 @@
chart.options.scales.x['max'] = getConvertedDistance(data.statistics.distance.total); chart.options.scales.x['max'] = getConvertedDistance(data.statistics.distance.total);
// update units // update units
chart.options.scales.x.title.text = `${$_('quantities.distance')} (${getDistanceUnits()})`;
chart.options.scales.y.title.text = `${$_('quantities.elevation')} (${getElevationUnits()})`;
for (let [id, dataset] of Object.entries(datasets)) { for (let [id, dataset] of Object.entries(datasets)) {
chart.options.scales[`y${id}`].title.text = chart.options.scales[`y${id}`].title.text =
dataset.getLabel() + ' (' + dataset.getUnits() + ')'; dataset.getLabel() + ' (' + dataset.getUnits() + ')';