Add units to graph tooltip
This commit is contained in:
parent
8e47638108
commit
72d85618a3
|
@ -9,11 +9,13 @@ function set_daily_graph(repoDict) {
|
|||
|
||||
var datasets = []
|
||||
repoDict.repos.forEach(function (repo) {
|
||||
datasets.push({label: repo.label,
|
||||
datasets.push({
|
||||
label: repo.label,
|
||||
data: repo.daily_size,
|
||||
fill: false,
|
||||
tension: 0.1,
|
||||
borderColor: 'rgb(75, 192, 192)'});
|
||||
borderColor: 'rgb(75, 192, 192)'
|
||||
});
|
||||
})
|
||||
|
||||
const data = {
|
||||
|
@ -25,19 +27,33 @@ function set_daily_graph(repoDict) {
|
|||
type: 'line',
|
||||
data,
|
||||
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: {
|
||||
y: {
|
||||
ticks: {
|
||||
display: true,
|
||||
grid: false,
|
||||
callback: function(value, index, values) {
|
||||
callback: function (value, index, values) {
|
||||
return value + " " + y_units;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var myChart = new Chart(
|
||||
document.getElementById('backup_csize_hourly'),
|
||||
|
|
Loading…
Reference in New Issue
Block a user