Browse Source

add descriptor labels in custom tooltip in stats

master
o.moresis 2 years ago
parent
commit
d3ef23cc1c
  1. 18
      public/js/stats.js

18
public/js/stats.js

@ -32,9 +32,10 @@ async function populateTimeseries(category) {
response.json().then(response => { response.json().then(response => {
const data = response.map(row => ({ const data = response.map(row => ({
x: row.sampling_date, x: row.sampling_date,
y: parseInt(row.counts) y: parseInt(row.counts),
details: row.details
})); }));
console.debug(data); console.debug(response);
const chartOptions = { const chartOptions = {
type: 'bar', type: 'bar',
@ -65,9 +66,20 @@ async function populateTimeseries(category) {
length: 4 length: 4
} }
} }
},
plugins: {
tooltip: {
callbacks: {
label: function(tooltipItems) {
console.debug('adsfasdfasdf',tooltipItems);
return tooltipItems.raw.details;
}
}
}
} }
} }; }
};
const ctx = document.getElementById(category + '-timeseries').getContext('2d'); const ctx = document.getElementById(category + '-timeseries').getContext('2d');
new Chart(ctx, chartOptions); new Chart(ctx, chartOptions);

Loading…
Cancel
Save