total in global graph tooltip

This commit is contained in:
Gwenhael Le Moine 2017-12-15 19:38:48 +01:00
parent 9a16fa1069
commit 923957aab4
No known key found for this signature in database
GPG key ID: FDFE3669426707A7

View file

@ -75,12 +75,12 @@ app.component('dashboard',
tooltip: { tooltip: {
contentGenerator: function(e) { contentGenerator: function(e) {
let format_line = (serie) => { let format_line = (serie) => {
return ` return `
<tr> <tr>
<td style="background-color: ${serie.color}"> </td> <td style="background-color: ${serie.color}"> </td>
<td>${serie.key}</td> <td>${serie.key}</td>
<td style="text-align: right; font-weight: bold;">${serie.value}</td> <td style="text-align: right; font-weight: bold;">${serie.value}</td>
</tr> </tr>
`; `;
}; };
@ -90,10 +90,19 @@ app.component('dashboard',
return series.filter((s) => { return s.value != 0; }); return series.filter((s) => { return s.value != 0; });
}; };
return ` return `
<h2>${e.value}</h2> <h2>${e.value}</h2>
<table> <table>
${prepare_series(e.series).map((s) => { return format_line(s); }).join("")} <tbody>
${prepare_series(e.series).map((s) => { return format_line(s); }).join("")}
</tbody>
<tfoot>
<tr>
<td> </td>
<td style="text-align: right; text-decoration: underline; font-weight: bold;">Total</td>
<td style="text-align: right; font-weight: bold;">${e.series.reduce((memo, serie) => { return memo + serie.value; }, 0)}</td>
</tr>
</tfoot>
</table> </table>
`; `;
} }