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

Loading…
Cancel
Save