Index: binaries/data/mods/public/gui/summary/summary.js =================================================================== --- binaries/data/mods/public/gui/summary/summary.js +++ binaries/data/mods/public/gui/summary/summary.js @@ -370,6 +370,54 @@ } chart.series = series; + + let size = chart.getComputedSize(); + let pixel2index = g_GameData.sim.timeElapsed/1000 + /g_GameData.sim.playerStates[1].sequences.time[1] + /(size.right-size.left); + + // Add and update a tooltip to the Chart, showing the y-values for each player. + chart.onMouseMove = function(mouse){ + + // Calculate the index colsest to the time the mouse use is hoverieng over. + let index = ( pixel2index*(mouse.x - size.left) ).toFixed(0); + + // Create [player-color, value] pairs + let values = []; + + for (let series in chart.series) + { + if (index < chart.series[series].length) + { + values.push([setStringTags("■ ", { "color": chart.series_color[series] }), + chart.series[series][index].y] + ); + } + } + + values.sort(function (x,y){return y[1]-x[1]}); + + // Format the numbers + switch (chart.format_y) + { + case "PERCENTAGE": + values = values.map(value => value[0] + value[1] + "%"); + break; + + case "DECIMAL2": + values = values.map(value => value[0] + (Infinity === value[1] ? + " " + g_InfinitySymbol : value[1].toFixed(2) + )); + break; + + default: + // Integers and default: + values = values.map(value => value[0] + value[1]); + } + + chart.tooltip = timeToString(1000*g_GameData.sim.playerStates[1].sequences.time[index]) + + ":\n" + values.join("\n"); + }; } function adjustTabDividers(tabSize)