Add units to graph tooltip
This commit is contained in:
parent
8e47638108
commit
72d85618a3
|
@ -9,35 +9,51 @@ function set_daily_graph(repoDict) {
|
||||||
|
|
||||||
var datasets = []
|
var datasets = []
|
||||||
repoDict.repos.forEach(function (repo) {
|
repoDict.repos.forEach(function (repo) {
|
||||||
datasets.push({label: repo.label,
|
datasets.push({
|
||||||
|
label: repo.label,
|
||||||
data: repo.daily_size,
|
data: repo.daily_size,
|
||||||
fill: false,
|
fill: false,
|
||||||
tension: 0.1,
|
tension: 0.1,
|
||||||
borderColor: 'rgb(75, 192, 192)'});
|
borderColor: 'rgb(75, 192, 192)'
|
||||||
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
labels: labels,
|
labels: labels,
|
||||||
datasets: datasets
|
datasets: datasets
|
||||||
};
|
};
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
data,
|
data,
|
||||||
options: {
|
options: {
|
||||||
|
plugins: {
|
||||||
|
tooltip: {
|
||||||
|
callbacks: {
|
||||||
|
label: function (context) {
|
||||||
|
var label = context.dataset.label || '';
|
||||||
|
if (context.parsed.y !== null && y_units !== null) {
|
||||||
|
return `${context.parsed.y} ${y_units}`
|
||||||
|
} else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
scales: {
|
scales: {
|
||||||
y: {
|
y: {
|
||||||
ticks: {
|
ticks: {
|
||||||
display: true,
|
display: true,
|
||||||
grid: false,
|
grid: false,
|
||||||
callback: function(value, index, values) {
|
callback: function (value, index, values) {
|
||||||
return value + " " + y_units;
|
return value + " " + y_units;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
var myChart = new Chart(
|
var myChart = new Chart(
|
||||||
document.getElementById('backup_csize_hourly'),
|
document.getElementById('backup_csize_hourly'),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user