Fixes for GPU rendering and more readable tooltip with render time
This commit is contained in:
@@ -20,6 +20,29 @@ function generateBarColor(index) {
|
||||
color[2].toString() + ")";
|
||||
}
|
||||
|
||||
function padValue(value, size) {
|
||||
var s = String(value);
|
||||
while (s.length < (size || 2)) {
|
||||
s = "0" + s;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
function secondsToHumanReadable(seconds) {
|
||||
var h = Math.floor((seconds %= 86400) / 3600);
|
||||
var m = Math.floor((seconds %= 3600) / 60);
|
||||
var s = Math.floor(seconds % 60);
|
||||
var msec = Math.floor((seconds % 60) % 1 * 100);
|
||||
var result = "";
|
||||
if (h != 0) {
|
||||
result += h + ":";
|
||||
}
|
||||
result += padValue(m, 2) + ":";
|
||||
result += padValue(s, 2) + ".";
|
||||
result += msec;
|
||||
return result;
|
||||
}
|
||||
|
||||
function buildChart(ctx, data) {
|
||||
var max_value = 0;
|
||||
for (dataset of data.datasets) {
|
||||
@@ -43,6 +66,21 @@ function buildChart(ctx, data) {
|
||||
scaleLabel: {display: true,
|
||||
labelString: 'Render time (sec)'},
|
||||
ticks: {min: 0,
|
||||
max: Math.ceil(max_value * 1.25)}}]}}
|
||||
max: Math.ceil(max_value * 1.25)}}]},
|
||||
tooltips: {mode: 'index',
|
||||
callbacks: {
|
||||
footer: function(tooltipItems, data) {
|
||||
var human_time = "";
|
||||
tooltipItems.forEach(
|
||||
function(tooltipItem) {
|
||||
var render_time = data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
|
||||
human_time = secondsToHumanReadable(render_time);
|
||||
}
|
||||
);
|
||||
return "Render Time: " + human_time;
|
||||
},
|
||||
},
|
||||
footerFontStyle: 'normal'},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user