Fixes for GPU rendering and more readable tooltip with render time

This commit is contained in:
2017-08-18 16:46:32 +02:00
parent 70ae2ff9dd
commit 69246133ec
2 changed files with 41 additions and 3 deletions

View File

@@ -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'},
}
});
}