Add game source to tooltip in games chart

Show service name (Steam, Local, Gog, etc.) below the bold game title
when hovering over chart segments.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Miguel Astor
2026-02-25 18:53:41 -04:00
parent bc0a541034
commit 3cc572a45b

View File

@@ -742,11 +742,28 @@ HTML_TEMPLATE = """<!DOCTYPE html>
}
},
tooltip: {
titleFont: {
weight: 'bold'
},
bodyFont: {
weight: 'normal'
},
callbacks: {
title: function(context) {
return context[0].label;
},
beforeBody: function(context) {
const index = context[0].dataIndex;
const service = chartData[index].service;
if (service && service !== 'others') {
return service.charAt(0).toUpperCase() + service.slice(1);
}
return '';
},
label: function(context) {
const value = context.raw;
const percent = ((value / totalPlaytime) * 100).toFixed(1);
return ' ' + formatTime(value) + ' (' + percent + '%)';
return formatTime(value) + ' (' + percent + '%)';
}
}
}